Same-bar execution
Flags execution timestamps that are not causally later than the signal bar close.
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.
python -m pip install backtest-integrity-guard
Current release: 0.2.2 · Python 3.10+ · MIT · no runtime dependencies.
Flags execution timestamps that are not causally later than the signal bar close.
Checks a declared cadence and reports undeclared gaps instead of silently accepting them.
Fails closed when stop and target both hit inside one OHLC bar without an explicit policy.
Distinguishes an exact duplicate bar from same-timestamp rows that disagree on OHLC(V).
# 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 .
Stable JSON schema, tool version, deterministic serialization, and optional SHA256 binding to the audited file.
Map vendor-specific timestamp/OHLCV column names without silently guessing missing fields.
Allow known breaks intentionally while keeping undeclared gaps fail-closed.
Works on CSV exports from custom research code or existing backtesting engines.
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.