Open-source backtest integrity tooling

Catch invalid assumptions before you trust the equity curve.

Backtest Integrity Guard is a dependency-free Python CLI for checking OHLCV integrity, signal-to-execution causality, same-bar exit ambiguity, and frozen research inputs. It is designed to sit beside your existing backtester—not replace it.

Install in one command

python -m pip install backtest-integrity-guard

Current release: 0.2.2 · Python 3.10+ · MIT · no runtime dependencies.

Four failure modes worth checking first

Same-bar execution

LOOKAHEAD_OR_SAME_BAR_ENTRY

Flags execution timestamps that are not causally later than the signal bar close.

Missing bars

MISSING_BARS

Checks a declared cadence and reports undeclared gaps instead of silently accepting them.

Ambiguous exits

AMBIGUOUS_SAME_BAR_EXIT

Fails closed when stop and target both hit inside one OHLC bar without an explicit policy.

Timestamp conflicts

TIMESTAMP_CONFLICT

Distinguishes an exact duplicate bar from same-timestamp rows that disagree on OHLC(V).

Quick audit

# OHLCV integrity + exact input hash
btguard ohlcv bars.csv --interval-seconds 300 --hash-input

# Signal-to-execution causality
btguard ledger trades.csv --hash-input

# Freeze research inputs
btguard freeze bars.csv trades.csv -o manifest.json --root .
btguard verify manifest.json --root .

Designed for explicit, reproducible assumptions

Deterministic reports

Stable JSON schema, tool version, deterministic serialization, and optional SHA256 binding to the audited file.

Vendor schemas

Map vendor-specific timestamp/OHLCV column names without silently guessing missing fields.

Explicit session gaps

Allow known breaks intentionally while keeping undeclared gaps fail-closed.

Framework agnostic

Works on CSV exports from custom research code or existing backtesting engines.

What it does not claim to solve

It does not model commissions, slippage, market impact, exchange calendars, order-book fills, survivorship bias, or strategy overfitting. The scope is narrower: make several common research-integrity assumptions explicit, testable, and reproducible.