Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Quant Backtest Guard?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/sickn33-quant-backtest-guard)
---
name: quant-backtest-guard
description: "Audit Python quantitative trading backtests statically for look-ahead bias, full-sample leakage, zero friction, and crypto perp funding omissions."
category: development
risk: safe
source: self
source_type: self
license: MIT
license_source: "https://github.com/Tomsabay/quant-backtest-guard/blob/d87321f45273af0e55218385d2dec8861327efda/LICENSE"
date_added: "2026-11-29"
author: Tomsabay
tags: [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
```text
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
- [MIT-licensed upstream reference](https://github.com/Tomsabay/quant-backtest-guard/tree/d87321f45273af0e55218385d2dec8861327efda). Use the checklist with local strategy source.