Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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+. After the package is published to PyPI:

python -m pip install backtest-doctor

Until PyPI publication, install the wheel from a verified release artifact or install this repository from source:

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

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.

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.0rc4

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.0rc4
File Size Uploaded Provenance Actions
backtest_doctor-0.4.0rc4.tar.gz 39.4 kB With provenance Details for backtest_doctor-0.4.0rc4.tar.gz

Built distribution (wheel)

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

Total release size: 58.2 kB

Release files / backtest_doctor-0.4.0rc4.tar.gz

Download URL backtest_doctor-0.4.0rc4.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e94270514b64ca9f93b80666427e2fe3e6c58a542ef092e0853d6d6c92011659
BLAKE2b-256 checksum
How to use checksums
16b414287022443349eb516eacd84599c2d516f08efaf6b5f9dc60b0d79c6cbc
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 2, 2026.

Transparency log

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

Download URL backtest_doctor-0.4.0rc4-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f793cec2252a5c68d09cc43188cb216860970be58f22d3e8a63b4e4e8d6e3e57
BLAKE2b-256 checksum
How to use checksums
cf9aae1f4b5bf4d1625f507336c0af2a164a274f490fa7df9dc7a227f6a22c13
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 2, 2026.

Transparency log

Security for backtest-doctor 0.4.0rc4

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.0rc4.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 2, 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