Skip to main content

Backtest Integrity Guard

tests PyPI version Open In Colab

Project site: https://suguobin2021.github.io/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 PyPI

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

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.

Guides

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.3

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.3
File Size Uploaded
backtest_integrity_guard-0.2.3.tar.gz 11.4 kB Details

Built distribution (wheel)

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

Total release size: 20.6 kB

Release files / backtest_integrity_guard-0.2.3.tar.gz

Download URL backtest_integrity_guard-0.2.3.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ae36c253e5e2774e62068c319f8768d0685d07cd913613ee7acc1ce715442b78
BLAKE2b-256 checksum
How to use checksums
251449ddf62be27e14a45e31aebc638e6152917e2b2b9b34a4a44a5faa2f278f
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 5, 2026.

Transparency log

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

Download URL backtest_integrity_guard-0.2.3-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb3aab7a9cd65414f5130360a88df05c9183f4fbbc4ed9b52b093f136db79b07
BLAKE2b-256 checksum
How to use checksums
236854206ca141049a737786dcc8661e4ce310924a1b91b7bcc3b0c43a13dca6
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 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

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