Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backtest Engine

backtest_engine is a standalone, explicit-input Gauntlet for backtest evidence. It has no market-data download, broker, exchange, queue, strategy, credential, or personal-path dependency.

It validates strictly increasing, OHLC-consistent native one-minute bars; fill resolution; strictly point-in-time features; causal level/geometry evidence; bound tick replay for ambiguous trades; frozen chronological OOS partitions; append-only trial/OOS provenance; and deterministic statistical diagnostics. A caller-supplied materialized-trade frame is not fill-validated unless it is nonempty and carries a hash-bound fills.v1 attestation.

Install and run

git clone https://github.com/GageBS/backtest-engine.git
cd backtest-engine
python -m pip install .
backtest-gauntlet --bars bars.csv --artifact-dir artifacts
python examples/minimal_gauntlet.py

The CLI prints one canonical machine-readable JSON report. Exit codes are 0 PASS, 1 FAIL, 2 UNVERIFIED, and 64 malformed input. It accepts portable CSV/JSON evidence for trades/intents/ticks/orders/replays, causal feature/level/geometry source frames and bounded derivation specs, frozen partitions, selection records, trial ledger/manifest and OOS spend state, attestations, session boundaries, and a statistical candidate-return matrix. Run backtest-gauntlet --help for the complete flag list.

Public contract

Call run_gauntlet with explicit pandas bars plus any applicable materialized trades, tick-replay records, features, causal source frames/derivations, selection records, partition, trial ledger, and candidate return matrix. It writes a digest-bound partition.json (when applicable) and gauntlet-report.json only below the caller-selected artifact directory. The report includes hashes of supplied evidence.

Applicable evidence that is missing or empty fails closed. In particular, empty or unresolved intents and an empty materialized-trade frame are UNVERIFIED for fills, even with an otherwise valid attestation. Scopes explicitly marked False in applicability are reported as UNVERIFIED with a reason; they never silently pass. A report is PASS only when every required gate genuinely ran and passed. Instrument costs use round_trip_cost_points, converted to R from each trade's positive finite abs(entry - stop) risk. The legacy round_trip_cost configuration field remains a deprecated point-unit alias.

The integrated institutional statistics gate requires a finite, nonempty candidate-return matrix with at least two candidates. Its CPCV selects on purged/embargoed training groups and ranks the selected candidate OOS. The cpcv function's one-series output is path diagnostics only; it does not claim PBO. Python API callers may provide causal derivation callables; CLI evidence deliberately uses only the bounded prior_min/prior_max declarative registry.

Scope and exclusions

This package intentionally excludes strategies, raw or licensed data, research results, credentials, personal paths, broker/exchange integrations, queue modelling, private ledgers, and governance/operations tooling. It makes no execution-quality or broker-connectivity claim.

See the compatibility contract for the portable law-to-module map. Contributions must retain explicit inputs, caller-owned artifacts, deterministic synthetic coverage, and the same exclusions.

About

Backtest Engine — portable Gauntlet-style validation for backtest trade outcomes

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages