Skip to content

About

Zero-dependency Python AST linter & Agent Skill that catches 10 fatal quant backtest traps (look-ahead bias, full-sample leakage, A-share T+1/limit-up, zero friction, survivorship bias) in 20ms.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quant-backtest-guard

CI License: MIT Python 3.9+

# Install as an Agent Skill (Claude Code / Codex / Cursor / Antigravity / OpenClaw)
npx skills add Tomsabay/quant-backtest-guard

Zero-dependency Python AST & static linter that catches 10 fatal backtest traps (look-ahead bias, full-sample scaler leakage, missing A-share T+1 / price-limit filters, zero friction, survivorship bias, and OOS-free grid-search overfitting) in 20ms before live trading.

专为 A股 / 美股 量化策略(pandas / Backtrader / 聚宽 jqdata / QMT / PTrade / AKShare / Tushare)打造的零依赖回测防未来函数静态体检工具 & Claude Code / Cursor Skill。

Zero-Install 20ms Online AST Sandbox (EN / 中文): https://stylefuse.top/quant-guard/
Alipay SkillPay 官方买断包(¥19.90): https://skillpay.alipay.com/shelf/product?productId=P0806000215821153&merchantId=2088522331444507
Live Cross-Exchange Funding-Rate & Polymarket Radar: https://stylefuse.top/arb/
Multi-Agent Architecture & Guardrails Audit: https://stylefuse.top/agent-audit/


10 Backtest Failure Modes Detected (20ms, Zero Dependencies)

Rule Code Severity What It Catches
LOOKAHEAD_NEGATIVE_SHIFT ERROR .shift(-k), .pct_change(-k), .diff(-k) peeking future bars in features/signals
LOOKAHEAD_BFILL ERROR .bfill() / fillna(method='bfill') back-filling history with future prices
LOOKAHEAD_CENTERED_ROLLING ERROR .rolling(..., center=True) sliding window leaking future bars
LOOKAHEAD_FULL_SCALER ERROR Global .fit_transform() or (x - x.mean()) / x.std() without train/test split or rolling window
LOOKAHEAD_SAME_BAR_CLOSE_EXEC WARN strategy_ret = signal * ret missing .shift(1) (same-bar close execution bias)
FRICTION_ZERO_COST WARN commission=0 or zero commission/stamp-duty/slippage deduction
ASHARE_MISSING_LIMIT_FILTER WARN A-share tickers (600xxx/000xxx/300xxx/AKShare/QMT/JQ) without limit-up/down & halt filter
ASHARE_MISSING_T1_GUARD INFO A-share strategy missing explicit T+1 sellable-position guard
SURVIVORSHIP_HARDCODED_UNIVERSE WARN Small hardcoded list of current winner tickers without historical constituents/delisted stocks
OVERFIT_NO_OOS_SPLIT WARN Nested parameter grid loops with no out-of-sample / walk-forward validation

Quick Start

git clone https://github.com/Tomsabay/quant-backtest-guard.git
cd quant-backtest-guard

# Audit a single strategy script (Markdown report)
python3 scripts/quant_guard.py path/to/strategy.py --format md

# Audit a whole strategy folder in CI (JSON output; exit code 2 on ERROR findings)
python3 scripts/quant_guard.py ./strategies/ --format json

Includes a ready-to-use SKILL.md for Claude Code, Cursor, Codex, and Windsurf.

Related Open-Source Tools

  • dialectic-agent-kit — Deterministic guardrails for multi-agent debugging & code review (verbatim citation verifier + consensus router)
  • abaqus_agent — Autonomous FEA workbench & MCP server for Abaqus
  • moonbit-snapstl — Zero-dependency watertight 2-manifold CSG & Binary STL kernel in MoonBit 1.0

About

Zero-dependency Python AST linter & Agent Skill that catches 10 fatal quant backtest traps (look-ahead bias, full-sample leakage, A-share T+1/limit-up, zero friction, survivorship bias) in 20ms.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages