Skip to main content

Backtest Doctor

License: MIT Python 3.10+

An offline, zero-runtime-dependency integrity check for exported backtests. Validate timestamped OHLCV data, declared signal-to-fill timing, and how aggregate trade returns change under transaction costs. Produce deterministic, minimal JSON and self-contained HTML reports without including raw trades or filenames.

This tool checks the evidence you supply. It does not inspect or execute strategy source code; it cannot prove a strategy is free of look-ahead bias, overfitting, survivorship bias, or execution risk. PASS means only that the implemented checks found no violations in the supplied fields.

Install

Requires Python 3.10+. The independently verified public package is currently a prerelease, not a stable release. Install the verified version explicitly:

python -m pip install --pre "backtest-doctor==0.4.0rc4"
python -m backtest_doctor --version

Alternatively, install from the audited GitHub Release or from this source checkout:

python -m pip install .
python -m backtest_doctor --help

PyPI project · Distribution guidance.

30-second synthetic demo

# Run from the repository root; ALL sample files are synthetic.
python -m backtest_doctor bundle \
  --ohlcv-file examples/ohlcv_good.csv \
  --ledger-file examples/ledger_bad.csv \
  --stability-file examples/stability_demo.csv \
  --html doctor-report.html --fail-on-warn

The intentionally bad ledger produces FAIL and exits 1; this is expected, not an installation failure. Try examples/ledger_good.csv instead to see a clean causal timing check. Stability may still return WARN for small samples. The command exits 0 for PASS, 1 for FAIL (and WARN with --fail-on-warn), and 2 for rejected input. For an HTML report opened locally, use a new filename; the CLI will not overwrite an existing file.

For a complete cross-platform, beginner-friendly walkthrough, follow the synthetic quickstart. For the manual, secretless PyPI publishing process, see the distribution guide.

For CI integration in other repositories, see the experimental GitHub Action.

Verified public-only three-framework format guide, synthetic showcase, Android Termux guide, and changelog.

Add --explain to any audit command for fixed, data-free diagnostic explanations and investigation suggestions. Explanations are opt-in, preserving the default JSON format. See the finding guide.

NEW: experimental framework-export CSV adapters: inspect settled trade summaries from backtesting.py, vectorbt, or a manually prepared Freqtrade CSV subset (not native Freqtrade ZIP/JSON):

python -m backtest_doctor import-trades examples/backtesting_py_synthetic.csv --framework backtesting-py
python -m backtest_doctor import-trades examples/vectorbt_synthetic.csv --framework vectorbt
python -m backtest_doctor import-trades examples/freqtrade_csv_synthetic.csv --framework freqtrade-csv

These checks cannot verify causal signal timing, and they do not double-count framework-reported costs by default. See framework CSV contracts, known limits and privacy model.

For synthetic examples of alternate CSV column names (without copying any private exports), see declarative column mapping.

Checks

Mode Input Detects / summarizes
ohlcv CSV with timestamp,open,high,low,close,volume Invalid candle geometry, duplicate/non-monotone timestamps, irregular cadence (when configured)
ledger CSV with signal_bar_close,entry_time,next_bar_open Entry before or at signal close; entry before claimed next bar; both stop and target hit within the same bar
stability CSV with exit_time,gross_return Trade count, time-coverage warnings, cost-scenario expectancy, PF, win rate, simplified sequential equity/drawdown proxies
bundle All three CSVs All checks, one aggregate report and exit status

Single-mode invocation:

python -m backtest_doctor ohlcv examples/ohlcv_good.csv --interval-seconds 60
python -m backtest_doctor ledger examples/ledger_bad.csv
python -m backtest_doctor stability examples/stability_demo.csv

Profit factor is undefined (reported as null) if no negative trades exist. All stability returns are fractions: 0.01 means 1%. Compounded returns and drawdown are explicitly proxies, not portfolio NAV or account-level PnL. Overlapping trades, leverage, funding, slippage, execution limits and corporate actions are not reconstructed. Costs are specified in basis points per trade (default 0, 8, 20 bps).

Privacy model

No networking, telemetry, trade execution, or strategy source evaluation. Reads local regular CSV files only (up to 10 MiB, 100,000 rows) and emits aggregate metrics and coded findings only. It is intentionally not a security sandbox: do not use it to evaluate untrusted adversarial filesystem access, and inspect reports before sharing. See SECURITY.md.

This repo uses synthetic fixtures only. It has no live trading records, private quantitative research databases, exchange API keys, real account IDs, strategy-specific parameters, server credentials, or licensed market datasets. Only explicitly allowlisted code, docs, tests, and synthetic fixtures are bundled by the build process.

Contribute and reproducibility

python -m unittest discover -s tests -v
python -m pip wheel . --no-deps -w dist

See CONTRIBUTING.md, docs/LIMITATIONS.md, and docs/RELEASE_CHECKLIST.md. MIT-licensed. No claim of investment performance or financial advice.

Metadata

Release files for backtest-doctor 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backtest-doctor 0.4.0
File Size Uploaded Provenance Actions
backtest_doctor-0.4.0.tar.gz 43.9 kB With provenance Details for backtest_doctor-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for backtest-doctor 0.4.0
File Interpreter ABI Platform Actions
backtest_doctor-0.4.0-py3-none-any.whl Python 3 none any Details for backtest_doctor-0.4.0-py3-none-any.whl

Total release size: 63.1 kB

Release files / backtest_doctor-0.4.0.tar.gz

Download URL backtest_doctor-0.4.0.tar.gz
Size 43.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b9f1efd2f6a21de90e12dbed3b85cb9c013192032bfbe40f578ff7fd2a7e2d94
BLAKE2b-256 checksum
How to use checksums
feb16f1af9fdb5794373aaf1b57dfa665fc26570762e6abeab9f918081eda09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / backtest_doctor-0.4.0-py3-none-any.whl

Download URL backtest_doctor-0.4.0-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65cc6e9af85e8d0bb5510f87c669fb8cd4841a9264523ae4daec314d26daca0a
BLAKE2b-256 checksum
How to use checksums
97192c250fdf0afae3d40ade2ebd69098451379f868a55fcadc99bf76b3cde86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for backtest-doctor 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for backtest_doctor-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page