Skip to main content

Deterministic Python research engine for prediction-market evidence-backed backtests

Project description

batter

Test PyPI version Python versions

Built for Pancake — receipts at https://usepancake.com/r/<receipt-id> use this engine to verify strategy math.

batter is a deterministic Python research engine for prediction-market evidence-backed backtests. Given a backtest spec and an EvidenceDataset, it produces a canonical result_hash — identical bytes across ubuntu / macos / windows on Python 3.12+ — enabling reproducible research and auditability of strategy claims. Engine 0.4 adds Monte Carlo bootstrap confidence intervals and a sign-permutation Sharpe test so credibility signals travel with every result.

The PyPI package is batter; the Python module is pancake_engine (sklearn-style rename: pip install batter then import pancake_engine).

What is this for?

Pancake is a prediction-market research platform. batter is the math layer, extracted as a standalone package so the formulas can be verified independently of the platform.

When a strategy backtest runs on Pancake, it runs through batter. The platform stores the result_hash; anyone can reproduce that hash locally by running the same spec and dataset through pip install batter. This is the platform connection: batter has origin in Pancake but is genuinely independently usable by anyone doing prediction-market research.

Install

pip install batter

Quickstart

import json
from pancake_engine import run_backtest, BacktestSpec, EvidenceDataset, BacktestConfig

spec    = BacktestSpec(**json.load(open("spec.json")))
dataset = EvidenceDataset(**json.load(open("dataset.json")))
config  = BacktestConfig()

result = run_backtest(spec, dataset, config)
print(result.result_hash)   # deterministic SHA-256 over canonical JSON
print(result.metrics.sharpe)
print(result.bootstrap_ci)  # 95% CI on cagr / sharpe / sortino (0.4+)

Determinism

The same (spec, dataset, config) produces the same result_hash across ubuntu / macos / windows on Python 3.12+. Verification method, fixture set, and numeric bounds are documented in docs/math-audit-0.4.md §"Verification verdict".

Supported Python versions: 3.12 and 3.13. Python 3.11 is permanently out of scope — sum() semantics changed in 3.12 (compensated float accumulation), causing the bootstrap CI values to differ by 1 ULP and producing a different result_hash. No code change can reconcile this without reverse-engineering 3.12's exact internal accumulation path. See docs/py311-investigation-2026-05-27.md for the full root-cause analysis and docs/math-audit-0.4.md §"Known scope qualifier — Python 3.11" for the audit entry.

Cross-platform

CI enforces a 6-cell matrix (ubuntu-latest + macos-latest + windows-latest) × (Python 3.12 + 3.13). See the badge above.

Cite batter

If you use batter in academic or independent research, please cite:

@software{mustopo2026batter,
  author       = {Mustopo, Michael},
  title        = {batter: Deterministic Python research engine for
                  prediction-market evidence-backed backtests},
  year         = {2026},
  version      = {0.6.0},
  url          = {https://usepancake.com/engine},
  repository   = {https://github.com/usepancake/batter},
  license      = {Apache-2.0},
  note         = {The math layer of usepancake.com. Produces canonical
                  SHA-256 result hashes reproducible across Ubuntu,
                  macOS, and Windows on Python 3.12+.}
}

License

Apache-2.0 — Copyright 2026 Michael Mustopo

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

batter-0.7.1.tar.gz (244.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batter-0.7.1-py3-none-any.whl (96.8 kB view details)

Uploaded Python 3

File details

Details for the file batter-0.7.1.tar.gz.

File metadata

  • Download URL: batter-0.7.1.tar.gz
  • Upload date:
  • Size: 244.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for batter-0.7.1.tar.gz
Algorithm Hash digest
SHA256 d4e28d1bbea39aa7ce3de7c786f9311e50c1a387ed322b9d158119af13bf2702
MD5 b0320009e5449ae4622e293e6a03f6f4
BLAKE2b-256 3098d0471ad508f9cf737e7c06d91a48e3f61390b9aa2ca8d3320cff9eca5373

See more details on using hashes here.

Provenance

The following attestation bundles were made for batter-0.7.1.tar.gz:

Publisher: publish.yml on usepancake/batter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file batter-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: batter-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 96.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for batter-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0eaac2b1dd7cd9250cdf721dc132b4771a46643c97206bf76f3549194907ac2
MD5 10c80ecb7f3f651b5610b80c199f3dc0
BLAKE2b-256 d62d85ace5092410da9c001eb070d87ddd149a4f55c59a470fcbba8e6a98db59

See more details on using hashes here.

Provenance

The following attestation bundles were made for batter-0.7.1-py3-none-any.whl:

Publisher: publish.yml on usepancake/batter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page