← LeaderboardThe Skill Leaderboard

quant-backtest-guard

Audit Python quantitative trading backtests statically for look-ahead bias, full-sample leakage, zero friction, and crypto perp funding omissions.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: quant-backtest-guarddescription: "Audit Python quantitative trading backtests statically for look-ahead bias, full-sample leakage, zero friction, and crypto perp funding omissions."category: developmentrisk: safesource: selfsource_type: selflicense: MITlicense_source: "https://github.com/Tomsabay/quant-backtest-guard/blob/d87321f45273af0e55218385d2dec8861327efda/LICENSE"date_added: "2026-11-29"author: Tomsabaytags: [quant, backtesting, python, finance, static-analysis]

Quant Backtest Guard (13-Rule Static Leakage & Friction Auditor)

Overview

Quantitative backtests frequently produce illusory Sharpe ratios due to subtle look-ahead leaks and missing execution friction. This skill guides a deterministic read-only AST/code review across 13 failure modes covering US equities, A-shares, and crypto perpetual futures before any strategy moves to paper or live capital.

When to Use

  • Reviewing Python backtest scripts (pandas, vectorbt, backtesting.py, backtrader, nautilus_trader) before trusting equity curves.
  • Checking AI-generated trading strategies for silent future-peeking or omitted trading/funding costs.
  • Do not use this skill to provide financial advice or execute live broker orders.

Prerequisites

  • Read access to the local Python strategy/backtest files.
  • No network access, broker credentials, or external packages are required.

How It Works

1. Establish the inputs

Locate all strategy, signal-generation, and backtest evaluation .py files. Identify the asset class (equities, A-shares, or crypto perpetuals) so market-specific rules apply cleanly.

2. Audit across the 13 static rules

  1. Negative time shifts (.shift(-k), .pct_change(-k), .diff(-k)) used inside features or signals.
  2. Backward fills (.bfill(), .backfill(), fillna(method="bfill")) leaking future bars into history.
  3. Centered rolling windows (rolling(..., center=True)).
  4. Full-sample fit_transform() or full-series (x - x.mean()) / x.std() without train/test split or rolling/expanding windows.
  5. Execution priced before the inputs were observable. Verify signal time, order time and fill time before deciding whether a lag is needed.
  6. Full-window universe selection (.nlargest(), .sort_values(), .rank() on PnL/return columns without a prior rolling/in-sample window).
  7. Zero transaction cost (commission=0 or complete absence of commission/fee/slippage deduction).
  8. Perpetual-futures simulations that omit funding cash flows. Check venue-specific schedules, position direction and cash-flow signs.
  9. Benchmark comparisons that omit the exposures, costs or leverage relevant to the strategy.
  10. Nested parameter grid loops lacking an out-of-sample (OOS) or walk-forward split.
  11. Hardcoded small survivor universes (2-15 symbols without delisted/point-in-time constituents).
  12. A-share limit-up/limit-down and suspension filter omissions (close < high_limit).
  13. A-share T+1 sellable-position guard omissions.

3. Verify the result

Report each finding with its file and line, the feature and execution timing, and what evidence would confirm it. Separate proven leakage from leads for further review.

Examples

User request: Check my BTC perpetual backtest script for look-ahead bias before live paper trading.
Inputs: `strategy.py` containing `df['z'] = (df['close'] - df['close'].mean()) / df['close'].std()` and no funding rate deduction.
Expected result (illustrative): Flags `LOOKAHEAD_FULL_SCALER` and `CRYPTO_PERP_MISSING_FUNDING` with exact line numbers and proposes train-only scaling or causal rolling features plus venue-specific funding checks.

Limitations

  • Single-file static inspection cannot detect data-vendor survivorship bias hidden inside external CSV/Parquet files.
  • Cross-module dynamic resampling requires reviewing the upstream data-prep module as well.

Safety and side effects

Read-only static code inspection (risk: safe). Executes no strategy code, places no orders, and makes no network requests.

Sources and related skills