Historical backtesting coming soon
The deterministic candle engine works today, and the hosted Kalshi flow is in private acceptance testing. It remains labelled coming soon until its deployment, isolation, and end-to-end checks are complete.
Why this design
We don’t want a separate “backtest framework” with its own interface — that creates two codebases for one strategy. Instead we keep the Strategy / Venue / Context contracts and swap the implementations beneath them:
- Hosted paper:
Polymarket()→ current market data →PaperContext - Backtest:
HistoricalVenue→ normalized one-minute candles →BacktestContext
Same Strategy code, same risk envelope, same handlers. Only the plumbing differs.
Use the local developer harness
from banger.backtest import Backtester, InMemoryCandleSource
from my_strategy import MyStrategy
# Build a HistoricalDataset containing one binary market and normalized candles.
source = InMemoryCandleSource(dataset)
result = Backtester(
MyStrategy,
source,
starting_capital=10_000,
).run()
print(result.summary)
print(result.fills)Historical input
A HistoricalDataset describes one binary market, the requested period, optional settlement, and chronological one-minute candles. Each candle carries opening and closing bid/ask observations.
- Signals emitted at a candle close are eligible only at the next candle open, preventing same-candle look-ahead.
- Limit orders fill only when they cross the available opening book; missing book observations never invent a fill.
- Kalshi sizes floor to whole contracts, standard taker fees round to cents, and settlement applies only when it falls inside the period.
BacktestResult
Returned by Backtester.run():
result.summary # return, ending equity, fees, drawdown, orders/fills, settlement
result.equity_curve # chronological (timestamp, equity_usd) points
result.fills # deterministic simulated fills
result.data_hash # fingerprint of the normalized historical input
result.save_csv("equity.csv")Demo
See packages/sdk-python/examples/backtest_demo.py in the repo for a working end-to-end backtest against a synthetic random-walk source.
Caveats
- One-minute candle books cannot reproduce historical queue position, latency, intra-minute paths, or full depth. Results are estimates, not a promise of live execution quality.
- The MVP supports one Kalshi binary market and at most seven days per run. Multi-market portfolios and Polymarket are deferred.
- Hosted access remains unavailable publicly until the acceptance checklist passes and its database migration and Modal function are deployed together.