Skip to content
Back to skills

Quant Backtest Guard

ASecurity

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

  • 50,717 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
ai-agentspythonrustgotestinggitapi

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add sickn33/agentic-awesome-skills --skill quant-backtest-guard --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Quant Backtest Guard?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Quant Backtest Guard
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sickn33-quant-backtest-guard/badge)](https://www.skillsdirectory.com/skills/sickn33-quant-backtest-guard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Files in this skill

  • LICENSE1.1 KB
  • SKILL.md4.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.