Oracle Engine | Prediction Market Backtester
Prediction market backtesting and live trading system. Replicates real market conditions with clock abstraction and order simulation.
The Problem
Backtesting prediction market strategies requires realistic simulation of order execution, timing, and market impact. Most backtesting frameworks make assumptions that work for traditional markets but fail for prediction markets' unique characteristics: low liquidity, long settlement times, and binary outcomes.
Technical Approach
I designed a clock abstraction that enables identical strategy code to run live or in backtest mode. The clock interface handles time progression, price updates, and order lifecycle uniformly regardless of execution context.
The system separates concerns cleanly: - Exchange adapters normalize API responses from Kalshi, Polymarket, and future markets - Candle aggregators handle sparse data and synthetic bar generation - Order simulators apply realistic execution delays to prevent lookahead bias - Strategy logic remains completely decoupled from execution mode
Interesting Challenges
Prediction markets often have illiquid periods with sparse trades. Standard candlestick algorithms break when there are gaps. I built synthetic candle generation that interpolates during quiet periods without introducing artificial patterns.
Execution delay simulation was critical. In backtest mode, filling orders at current prices introduces severe lookahead bias. The system now simulates realistic fill prices by sampling from recent trade distributions.
What I'd Do Differently
The current architecture is synchronous. An event-driven approach with a message queue would better handle high-frequency updates from multiple exchanges simultaneously.
Key Features
- -Clock abstraction for live/backtest mode switching
- -Execution delay simulation for realistic backtests
- -Synthetic candle generation for illiquid markets
- -YAML configured strategy parameters
- -React dashboard with TradingView charts
- -Performance metrics (Sharpe, max drawdown, win rate)
Tech Stack
