batter
usepancake.com/engine · batter 0.4.2 · Python 3.12+ · Apache-2.0
What batter is
Deterministic Python research engine behind Pancake's receipts. The math layer of usepancake.com, extracted as a standalone package so anyone can verify the formulas independently. batter takes a validated strategy spec, an EvidenceDataset, and a run config — and produces a canonical result envelope with a SHA-256 result hash identical across Ubuntu, macOS, and Windows on Python 3.12+.
Every Pancake receipt carries an engine_version field. That version points to this package. Any reader can reproduce the receipt by running batter at the stated version against the cited dataset and comparing hashes.
Install
Install from PyPI. The package ships as batter; the Python module is pancake_engine.
pip install batter
import pancake_engine result = pancake_engine.run(spec=spec, dataset=evidence, config=config) print(result.result_hash) # SHA-256 hex — identical on every platform
Requires Python 3.12 or 3.13. Python 3.11 is permanently excluded — see py311-investigation for the technical rationale.
Role in the platform
When a Pancake receipt is computed, the pipeline runs in four stages:
- Spec validation— the agent's strategy spec is canonicalized and hashed (
spec_hash). - Tick evaluation — the spec is compiled to an IR, the EvidenceDataset rows are validated for structural invariants, and the position ledger is computed deterministically.
- Metrics + bootstrap CI — batter computes all 12 formulas and the Monte Carlo bootstrap confidence interval using a PCG64 seeded RNG.
- result_hash — a SHA-256 digest of the full output envelope. Same inputs → same hash on any platform.
The engine shim at lib/evidence-runner/ in the Pancake frontend calls batter over HTTP when PYTHON_ENGINE_URL is set; it falls back to the TypeScript runner for development. The TypeScript runner does not emit batter 0.4 CI fields — use the Python path for receipts with [CI: ...] values.
The 12 verified formulas
All 12 formulas were independently re-verified against published sources in the post-0.4.0 math audit (12/12 PASS). Reference implementations live in scripts/reverify/ in the pancake-production repo — each uses raw NumPy with no batter import, then asserts byte-equal or within published tolerance.
| # | Formula | Published source | batter API path |
|---|---|---|---|
| 1 | total return | Bacon 2008 §2.1 | metrics.standard.total_return |
| 2 | CAGR | Bacon 2008 §2.2 | metrics.standard.cagr |
| 3 | Sharpe | Sharpe 1994 (JPM) | metrics.standard.sharpe |
| 4 | Sortino | Sortino & Price 1994 (JoI) | metrics.standard.sortino |
| 5 | max drawdown | Magdon-Ismail & Atiya 2004 | metrics.standard.max_drawdown |
| 6 | win rate | Bacon 2008 §4.1 | metrics.standard.win_rate |
| 7 | Wilson CI | Wilson 1927 (JASA 22) | metrics.standard.win_rate_ci95_low/high |
| 8 | Brier | Brier 1950 (Monthly Weather Review) | metrics.standard.brier_crowd |
| 9 | Bootstrap percentile CI | Efron 1979 (Ann. Stat. 7) | metrics.bootstrap.bootstrap_ci |
| 10 | Sharpe p-value | Good 2005 (Springer §3) | metrics.permutation.permutation_p_sharpe |
| 11 | Daily return carry-forward | D-14 divergence-correct ref impl | metrics.series.daily_returns_carry_forward |
| 12 | Determinism (SHA-256) | math-audit-0.4 | Full-pipeline 25-run loop, zero hash drift |
Determinism guarantees
Same (spec, dataset, config) → same result_hash across Ubuntu, macOS, and Windows on Python 3.12+. Determinism rests on canonical JSON serialization, a PCG64 seeded RNG, and Python 3.12+'s float accumulation semantics. Python 3.11 is permanently excluded: a C-level sum() precision change in CPython 3.12 (gh-100946) introduces a 1-ULP difference that propagates through bootstrap CI into a completely different SHA-256 hash. There is no userspace patch.
Cite batter
If you use batter in academic or independent research, please cite:
BibTeX
@software{mustopo2026batter,
author = {Mustopo, Michael},
title = {batter: Deterministic Python research engine for
prediction-market evidence-backed backtests},
year = {2026},
version = {0.4.2},
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+.}
}Mustopo, M. (2026). batter: Deterministic Python research engine for prediction-market evidence-backed backtests (v0.4.2). https://usepancake.com/engine
Source & package
The engine is published under the Apache 2.0 license. The Methodology page documents the full verification boundary and math foundations in prose form.