Skip to main content

Backtest Integrity Guard

tests PyPI version Open In Colab

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 PyPI

python -m pip install backtest-integrity-guard
btguard --help

From a GitHub release

The GitHub release includes a wheel, source archive, and SHA256SUMS for users who want to verify exact artifacts.

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.2",
  "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/conflicting 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.2

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-integrity-guard 0.2.2
File Size Uploaded
backtest_integrity_guard-0.2.2.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for backtest-integrity-guard 0.2.2
File Interpreter ABI Platform
backtest_integrity_guard-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / backtest_integrity_guard-0.2.2.tar.gz

Download URL backtest_integrity_guard-0.2.2.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
10602cbf823fb766d6830dd5517f93dcd36205a69894ce797cf5e7c9664f61ba
BLAKE2b-256 checksum
How to use checksums
40d04799dd089e64ac74098a8816ece35777ad331373a2440d84a73828ac7e93
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

Release files / backtest_integrity_guard-0.2.2-py3-none-any.whl

Download URL backtest_integrity_guard-0.2.2-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb5af2968cb60d4ee974330335155c8fbcf5e35ee124f439947ac7b536fa97d9
BLAKE2b-256 checksum
How to use checksums
a89a4be845520c3f52e84361c1c39f4a2b2cbe886ee70d678b239de2659f4c4c
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

Release history Release notifications | RSS feed

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

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