These checks cover the mistakes our own research process is built to avoid. We hold that work to pre-registered tests, with the bar set before we see any results.
Backtest Auditor · Free on PyPI
Red-team your backtest before you rely on it.
Run it on your strategy code, return series or trade log and get a report on the errors that most often make a backtest look better than it is. Version 0.7 is an MCP server and Python library that you run locally, free on PyPI as backtest-auditor; its hosted web check is off until a version meets our pass rule on a later sealed test set.
See a look-ahead leak flagged
Illustrative example
import pandas as pddf = pd.read_csv("prices.csv", index_col="date")df["ret"] = df["close"].pct_change()df["signal"] = df["close"].shift(1) > df["close"]df["pnl"] = df["signal"].shift(1) * df["ret"]df["pnl"] -= df["signal"].diff().abs() * 0.001 # costsLA01highline 5
Uses tomorrow's price to decide today's trade
shift(-1) moves tomorrow's close onto today's row, so the signal knows the answer before the trade. The backtest can then show results no one could have traded.
Checker's rule title: Negative shift (future data) in a feature or signal
Fix applied (by you or your agent): df["close"].shift(-1) → df["close"].shift(1)
What this example shows
- A short pandas backtest is typed into the editor.
- The checker flags line 5.
- A high-severity finding explains that the signal uses tomorrow's price to decide today's trade.
- You (or your agent) apply the suggested fix: shift(-1) becomes shift(1), so the signal only uses past prices.
- The check is run again on the fixed code: none of the listed patterns match, which doesn't prove the backtest is free of leaks.
The rule ID, severity, line, rule title and both results are the checker's real output on this example snippet. The plain-English explanation was written for this demo, and the fix was made by hand.
What we check
Seven ways a backtest misleads you.
Lookahead bias
Using data that wasn't available when the trade would have been made, such as a day's closing price to trade at that day's open. It's one of the most common ways a backtest looks better than it should.
Survivorship bias
Testing only on companies that still exist today leaves out the ones that failed or were delisted, which tilts results upward.
Ticker reuse
Symbols get recycled and companies get renamed. Joining data on the symbol alone can splice two different companies into one price history. The trade-log check flags well-known symbols traded before their current company used them; it can't catch every reused ticker.
Unrealistic costs
Commissions, spreads and slippage add up. A high-turnover strategy can look fine before costs and lose money after them.
Overfitting and multiple testing
Try enough variations and one will look good by chance. You tell us how many variants you tried, and the Deflated Sharpe Ratio raises the bar to match.
Sub-period instability
A result that comes from one stretch of years may not hold in others. We split the test period into thirds and years and compare the pieces.
Concentration
If a handful of days or tickers produce most of the gains, the result is fragile. We measure how much comes from the best days and the biggest positions.
The tools
Six MCP tools, one report format.
Ask your AI assistant to run them, or call the same functions from Python. The server also offers three one-click prompts: “Find look-ahead bias in this repo”, “Audit this backtest before I rely on it” and “Draft a backtest from my idea”. The last one has your AI assistant write a strategy idea of your own from our template and run the code check on it before showing you any result.
check_pathA Python file, notebook or folder on disk
Reads the files without running them and flags lookahead and bias patterns, each with its exact lines and a one-line reason. For a few unambiguous patterns it suggests a minimal edit, which the server checks again before returning it. An edit changes what the code does, so review it like any other change.
audit_backtestYour code, returns or trade log, and an optional benchmark
Runs every check that applies in one call and gives one combined verdict, with the reasons for each part.
check_codePython strategy code pasted into the chat
Lints the code for lookahead and survivorship leaks, missing costs and similar mistakes. Each finding has a rule id, the line, why it inflates results and how to fix it.
audit_returnsA return series, as CSV or JSON
Checks costs and the break-even cost, Sharpe significance, the Deflated Sharpe Ratio for the number of variants you tried, sub-period stability, concentration, drawdown and a benchmark comparison.
audit_trade_logA CSV trade log: date, ticker, side, quantity, price
Rebuilds daily results from the trades, runs the same checks as audit_returns, and adds ticker concentration and survivorship hints.
explainA check id
Says what a check does, why it matters, how to fix it and where it comes from.
Audits of returns, trade logs and whole backtests end with a verdict: Major red flags, Some red flags, No red flags found. No red flags doesn't mean a strategy will make money; it means these checks didn't find the common errors.
Install
With uv there's no separate install step. Add it to Claude Code:
claude mcp add backtest-auditor -- uvx backtest-auditorFor Claude Desktop or Cursor, add {"command": "uvx", "args": ["backtest-auditor"]} under mcpServers. Or install it into a Python 3.12 environment:
pip install backtest-auditorPackage page: pypi.org/project/backtest-auditor. It runs on your machine, needs no API key and calls no data vendor.
Limits and your data
What it misses, and what we keep.
- In short. The Auditor's static checks catch some common look-ahead leaks and miss many. In our latest full-size sealed test (2026-10-18), they flagged 34 of 60 planted leaks. They can also flag correct code: in that test, 1 of 105 plain correct files and 4 of 55 correct files written to look like leaks (5 of 160 overall). On leaks that open-source developers had found and fixed in their own code, they flagged 2 of 28 in a first trial, then 5 of 22 and 0 of 10 in two small pilots, which may repeat examples from the first trial (in the first pilot, possibly most of them); with so few examples these counts are very uncertain. The full-size test and both pilots did not meet our pass rule. Treat a clean result as weak evidence, never as proof that a backtest is free of leaks.
- Our latest sealed test, v13, a small pilot. Sealed test v13 (2026-11-19), a pilot that did not meet our pass rule: this time the test files were leaks that open-source developers had found and fixed in their own code, each with its repaired version, collected from code that no rule writer or prompt author had seen beforehand. The test needed at least 20 usable leak-and-fix pairs and we found 10, so it counts as a small pilot, it reports counts only, and neither version could pass. The lint rules alone (a newer, unreleased version, v0.10) flagged 0 of 10 leaky versions (95% interval 0% to 28%), raised a false red flag on 0 of 10 repaired files (0% to 28%) and flagged 0 of 1 documented non-leak; the released Auditor 0.7 gave the same counts. The lint plus an optional AI review step (review_backtest, designed to run in the user's own AI assistant, tested here with Sonnet 5.5, one run) flagged 5 of 10 leaky versions (95% interval 24% to 76%), raised a false red flag on 0 of 10 repaired files (0% to 28%) and flagged 0 of 1 non-leak. With so few examples these counts are very uncertain. Two more limits: 3 of the 5 caught leaks were fixed before the AI model's training cutoff, so it may have seen those fixes, and 4 of the 5 catches came from a rerun of one batch, decided before any results were read, after a fault in our audit tool rejected the first attempt. An independent red-team reproduction matched every number; two examples were moved between our two repository groups, which changes no total. Nothing ships on this result: the package stays at 0.7.0, and the AI review step is not released and is still being tested. No full-size test of this kind (at least 20 usable pairs) has been completed yet.
- Our previous sealed test, v12, also a small pilot. Sealed test v12 (2026-11-15), a pilot that did not meet our pass rule: this time the test files were leaks that open-source developers had found and fixed in their own code, each with its repaired version. The test needed at least 20 repaired files that were clean where the fix was made, and we found 1, so it counts as a small pilot and no version could pass. Across all 24 examples, the released Auditor 0.7 and two newer unreleased versions gave the same results: they flagged 5 of 22 leaky versions, so they missed 17, and they raised a false red flag on 1 of 21 repaired versions, at the repaired lines. Of the 24 examples, 20 came from small, recent repositories, which our rules report separately; on the 4 that the pass rule counts, no version flagged either of the 2 leaky versions, so they also failed our minimum-catch rule. With so few examples these counts are very uncertain. Only the repaired lines were checked, so this is a narrower test of false alarms than the plain and look-alike files above. A list of fixes used in an earlier trial (real-code trial 1, below) was lost, so an unknown number of these examples, possibly most of them, may repeat that trial's examples. No new version is released on this result, and the free web check stays off.
- Our first real-code trial, a small test with no pass rule. Real-code trial 1 (2026-10-19), our first test on public code with documented leak fixes. It had no pass rule. Two independent AI agents labelled the files from the fixes alone; the 52 they agreed on were 28 leaky and 24 fixed or correct. The released Auditor 0.7 flagged 2 of 28 leaky files (95% interval 2% to 23%): 0 of 25 Python files and 2 of 3 notebooks. A newer unreleased version gave the same counts. It raised a high or medium red flag on 4 of 24 fixed or correct files; 1 of them is a confirmed false alarm, and the other 3 are fixed files with findings away from the fixed lines. With so few examples these counts are very uncertain. An independent red-team reproduction matched every number, but the labels were later lost, so this result can't be fully re-checked. Some of its examples may reappear in the v12 pilot.
- Our latest full-size sealed test. In our own held-out test (one test set, written for us and sealed before scoring, 2026-10-18), lint v0.7 raised a high or medium red flag on 1 of 105 plain correct files and on 4 of 55 correct files written to look like leaks (5 of 160 correct files overall). It flagged 34 of 60 deliberately leaky files (57%), so it misses many issues. Flags can be wrong, and a report with no red flags is weak evidence. We changed this test's pass rule after two earlier runs; all results, including the earlier ones, are on our Findings page. This result did not meet our pass rule, which allows no high or medium red flag on any plain correct file. Lint v0.7, the version on PyPI, flagged 1 of 105, and lint v0.8, a newer version tested on the same set, flagged 1 of 105, so we won't release v0.8. Until a version meets the rule on a later sealed test set, the free web check on this site is off. The Backtest Auditor package is still available, free on PyPI, and runs on your own machine. We changed this test's pass rule after two earlier runs. The old rule (no false alarms on any correct file) was not met: 3 of 80 correct files were flagged in one run and 4 of 90 in the next, all but one of them look-alike files. The new rule was fixed before the next test set was written.
- Your code is never executed. The Auditor reads it with static analysis only.
- Run locally, we never receive your code. Run locally (CLI or MCP), the Auditor makes no network calls. The hosted web check is off right now, so we hold no one's code.
Sample report
What a report will look like.
A layout preview for a made-up strategy file. It describes no real strategy.
Illustrative sample: a made-up strategy, not a real audit
Verdict: Major red flagsNo red flags doesn't mean a strategy will make money; it means these checks didn't find the common errors. Combined verdict for the code and the trade log. A high code finding makes it Major red flags. Code findings are marked high, medium or possible; the trade-log checks have no labels of their own and feed the verdict.
- Lookahead bias HighLA07, line 42: the signal for each day uses that day's close, but trades fill at that day's open.
- Survivorship bias MediumSB01, line 12: the universe is a hard-coded list of today's index members. Names that left the index are missing.
- Ticker reuse Trade-log checkNo symbol in the trade log was traded before its current company used it.
- Unrealistic costs PossibleCO01, line 57: no trading costs are modeled, and the reported Sharpe is computed from cost-free returns.
- Overfitting and multiple testing MediumLA11, line 30: a parameter grid of 48 variants was scored on the full sample, and only the best result is kept.
- Sub-period instability Trade-log checkResults have the same sign in each third of the test period.
- Concentration Trade-log checkThe best 5% of days carry about the share of gains a normal distribution would give.
This is a statistical and code review of a hypothetical backtest. It is not investment advice, a recommendation to trade any strategy or security, or a prediction of future results. It is not tailored to your finances, goals or risk tolerance. “No red flags found” means these checks didn't find these common errors; it doesn't mean a strategy will make money. The review depends on the information you provided, including the number of variants you tried. Reports are produced by software and can contain errors. Nothing But Alpha is not a registered investment adviser or broker-dealer.
Where the checks come from
Standards we hold ourselves to.
Related
Backtest hazard report (preview): Three example reports on how a list of tickers and a start date can mislead a backtest, before any code runs.
FAQ
Questions
What formats does it support?
Version 0.7 reads Python files and Jupyter notebooks for the code check, return series as CSV or JSON, and trade logs as CSV. It doesn't read Pine Script or other languages yet.
Is this investment advice?
No. The Auditor checks a backtest for common errors. It doesn't tell you whether to trade a strategy, and it isn't tailored to your finances or goals.
What do the verdicts mean?
Audits of a return series, a trade log or a whole backtest end with one of three verdicts: Major red flags, Some red flags, No red flags found. Each is followed by the same line: No red flags doesn't mean a strategy will make money; it means these checks didn't find the common errors. Code findings are marked high, medium or possible.
Will it flag every leak in my code?
No. Static checks miss many leaks. A clean code check is weak evidence, not a clean bill of health. In our latest full-size sealed test (our own test, one set, 2026-10-18), the released version flagged 34 of 60 planted leaks and raised a high or medium red flag on 1 of 105 plain correct files and 4 of 55 correct files written to look like leaks (5 of 160 overall). On leaks that open-source developers had found and fixed in their own code, it flagged 2 of 28 in a first trial, then 5 of 22 and 0 of 10 in two small pilots; with so few examples these counts are very uncertain. The full-size test and both pilots did not meet our pass rule. Results, misses included, are on this page.
Do you support MCP?
Version 0.7 is an MCP server with six tools (check_path, audit_backtest, check_code, audit_returns, audit_trade_log and explain) and three prompts. You run it locally. It's free on PyPI as backtest-auditor: start the MCP server with "uvx backtest-auditor", or install it with "pip install backtest-auditor".
What happens to my code and data?
Your code is never executed: the Auditor only reads it. Run locally (CLI or MCP), it makes no network calls, so we never receive your code. Your AI assistant is a different matter: anything you paste into it, and anything the tools return to it (findings quote file names and lines of code), goes to that assistant's provider under its terms. The hosted web check is off right now, so we hold no one's code.
When do you launch?
Backtest Auditor 0.7 is available now. We haven't set dates for later versions.