# backtest-integrity-audit

> Audit backtests for lookahead, survivorship, leakage, unrealistic fills and crypto data traps.

backtest-integrity-audit is a paid AI agent skill on Agensi by BanditXBT. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $29 (one-time purchase)
- Creator: [BanditXBT](https://www.agensi.io/creators/banditxbt)
- Version: 1.0
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/backtest-integrity-audit
- Tags: trading-investing, code-quality-review, research-analysis

## About this skill

Assume the backtest is wrong until each information path is proven causal. Goal: every number used at decision time t was knowable, tradable, and priced realistically at t. Educational analysis, not investment advice; state assumptions and data sources.

1. **Timeline map.** For each input (price, fundamental, signal, universe flag) record event time, availability time, decision time, execution time. Require `available_at <= decision_time < execution_time`.
2. **Shift test.** Delay every feature by one bar (then one more for latency). Honest edge decays smoothly; a collapse (heuristic: >50% Sharpe loss from one bar) suggests same-bar information or fill optimism.
3. **Placebo tests.** Permute signal ranks within date (expect IC and net Sharpe ~ 0); flip the signal sign (gross PnL should flip sign, net should be worse); run on synthetic random walks (any significant result is a bug).
4. **Truncation test.** Run the pipeline on data cut at T-k and on the full sample; diff signals/positions at T-k. Any difference is lookahead (full-sample scalers, fitted models, forward-filled revisions).
5. **Reproduce a few trades by hand** from raw tick/bar files, including fill price vs that bar's high/low.

**Lookahead**
- Same-bar signal and fill (close-to-close signal executed at that close): use next-bar open or modeled VWAP.
- Full-sample statistics: z-scores, PCA, vol scaling, hyperparameters, imputation, regime/HMM fits. Use expanding/rolling fits only.
- pandas traps: bar labeling in `resample`, `shift(-1)`, `rolling(center=True)`, `bfill`, `merge_asof(direction='nearest'|'forward')` (use `'backward'` with tolerance).
- Timezone/session mismatches; universe filters (ADV, price, cap) computed with future data.

**Survivorship and universe**
- Use point-in-time membership (index adds/deletes, listing/delisting dates), not today's constituents. Missing delisting returns bias results upward (Shumway 1997, "The Delisting Bias in CRSP Data").
- Crypto: today's top-N includes only survivors. Rebuild from historical snapshots and include dead tokens, rugs, delisted pairs.

## Requires

- Python 3
- pandas

## Known limitations

Educational analysis, not investment advice. Heuristic thresholds are judgment calls, not tested rules.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the backtest-integrity-audit skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What does backtest-integrity-audit do?

Audit backtests for lookahead, survivorship, leakage, unrealistic fills and crypto data traps.

### Which AI agents support backtest-integrity-audit?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use backtest-integrity-audit?

Connect your AI agent to Agensi through MCP, then ask it to use backtest-integrity-audit on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
