Backtest Integrity Guard
A small, dependency-free Python CLI for catching common integrity failures in quantitative backtests before performance metrics are trusted.
It focuses on causality, data integrity, explicit ambiguity handling, and reproducibility. It does not implement trading signals or ship market data.
Install
From the v0.2.1 release wheel
python -m pip install "https://github.com/suguobin2021/backtest-integrity-guard/releases/download/v0.2.1/backtest_integrity_guard-0.2.1-py3-none-any.whl"
btguard --help
The release also includes a source archive and SHA256SUMS.
From source
git clone https://github.com/suguobin2021/backtest-integrity-guard.git
cd backtest-integrity-guard
python -m pip install -e .
Quick start
Audit ordinary OHLCV data:
btguard ohlcv examples/ohlcv.csv --hash-input
Audit vendor-specific column names:
btguard ohlcv examples/vendor.csv --map examples/schema.json
Check a 5-minute cadence while explicitly allowing a known session break:
btguard ohlcv examples/session_gap.csv \
--interval-seconds 300 \
--allow-gaps examples/allowed_gaps.json
Audit signal-to-execution timing:
btguard ledger examples/trades.csv --hash-input
Freeze and verify research inputs:
btguard freeze examples/ohlcv.csv examples/trades.csv -o manifest.json --root .
btguard verify manifest.json --root .
Commands exit non-zero when an integrity error is found, so they can be used in CI.
Output contract
Audit output is deterministic JSON with a stable report schema:
{
"errors": 0,
"findings": [],
"input_sha256": "<64 hex chars>",
"report_schema_version": "1.0",
"status": "PASS",
"tool_version": "0.2.1",
"warnings": 0
}
Use --hash-input when a report should be bound to the exact audited file.
What it checks
- OHLC geometry and negative or invalid volume
- duplicate and non-monotonic timestamps
- timezone-aware timestamps
- incomplete-bar markers
- configurable OHLCV schema aliases
- missing bars and irregular cadence
- explicitly allowlisted session gaps
- signal-close to execution ordering
- next-bar execution constraints
- same-bar stop/target ambiguity
- SHA256 frozen-input manifests
- deterministic machine-readable reports
Scope
Backtest Integrity Guard intentionally does not contain:
- trading signals or alpha logic
- brokerage execution code
- proprietary or licensed market data
- account credentials or API keys
The goal is to make research assumptions machine-checkable without depending on any particular strategy.
Contributing
See CONTRIBUTING.md. Bug reports should include the smallest synthetic example that reproduces the problem.
Useful project links:
License
MIT.
Metadata
Release files for backtest-integrity-guard 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| backtest_integrity_guard-0.2.1.tar.gz | 10.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| backtest_integrity_guard-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / backtest_integrity_guard-0.2.1.tar.gz
| Download URL | backtest_integrity_guard-0.2.1.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3073dd0aac6df6b58aceb0902e6c6ab5f106f8564256eba9fdaa0b41c9189a2c
|
|
BLAKE2b-256 checksum How to use checksums |
dd79d0dea23970fde8794e38b27977b497256977071664910dc24e9b41d903fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 3, 2026.
Transparency logRelease files / backtest_integrity_guard-0.2.1-py3-none-any.whl
| Download URL | backtest_integrity_guard-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
021dd797168ef0bf39ae6893a6ce0e14fc872cffe4acb49fef501b73f52a8c1f
|
|
BLAKE2b-256 checksum How to use checksums |
c6f355155e3c51f2cef87e71fef1f349caa2d4d17808bcdc786e911b9114280e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 3, 2026.
Transparency log