Backtesting Engine
Monte Carlo + historical replay before you go live
The Backtesting Engine lets you test a trading strategy against the past before you ever risk capital on it. Instead of guessing whether "buy every market with a 5pp+ edge" or "fade everything above 95%" actually makes money, you run the rules through historical conditions and read back hard numbers: win rate, P&L, max drawdown, Sharpe ratio, and a full trade log. It lives at **/dashboard/backtest** and is the bridge between an idea and a live position.
This is one of the most-skipped tools on the platform, and that is exactly why disciplined traders lean on it. A strategy that feels obviously profitable in your head often produces a 48% win rate and an ugly drawdown once you replay it. Better to learn that here than in your account balance.
## What the Engine Actually Does
Predite runs **two complementary backtest engines** behind the same page. They answer different questions, and serious users run both.
### 1. Monte Carlo simulation
The main panel runs a Monte Carlo simulation that models how a strategy behaves across hundreds of simulated trading days. It is built on historical Polymarket statistics β average edge, edge variance, base win rate, and typical hold time for each strategy archetype β and then simulates day-by-day whether an opportunity appears, how big you'd size it, and how it resolves.
Crucially, the simulation is **deterministic per configuration**. The same inputs always produce the same result (it is seeded from a hash of your config), so you can tweak one parameter at a time and see exactly how it moves the outcome. Change the seed-bearing inputs and you get a fresh path. This makes Monte Carlo ideal for *parameter sweeps*: "what does raising my minimum edge from 5 to 10 do to win rate and trade count?"
Four strategy archetypes are available:
- **EV Follower** β follows AI edge signals; buys when the AI thinks a market is mispriced. Highest trade frequency, ~58% base win rate.
- β’**Mean Reversion** β fades extreme probabilities, expecting them to drift back toward the middle. Fewer, larger-edge trades.
- β’**Momentum** β rides price trends, shortest hold times, high frequency.
- β’**Contrarian** β bets against the crowd. Rare, high-conviction, high-variance trades.
### 2. Historical replay
Above the Monte Carlo panel sits the **replay widget** (labeled BETA). This is the more literal engine: it walks **real recorded market snapshots** chronologically and simulates entries and exits tick by tick. Where Monte Carlo asks "how should a strategy like this behave statistically," replay asks "what would *this exact strategy* have done on *this exact market's* actual price history."
Replay reads from the `market_snapshots` / `market_history` tables, which are populated by background crons (every 15 minutes for the snapshot feed, every 4 hours for the scan feed). Because of that, **replay needs accumulated data to be meaningful** β see the gotchas section.
## How to Run a Backtest, Step by Step
1. **Open /dashboard/backtest.** You'll land on the configuration card with sensible defaults already filled in ($10,000 capital, 5pp minimum edge, 6-month window). 2. **Pick a strategy** from the dropdown (EV Follower, Mean Reversion, Momentum, or Contrarian). This is the single biggest driver of your results. 3. **Set your starting capital.** Use a realistic number β the same one you actually plan to trade with. Position sizes scale off this, so $1,000 and $100,000 produce very different absolute P&L and drawdown. 4. **Configure entry β minimum edge.** This is your filter. The engine only "enters" a trade when the modeled edge clears this threshold (in percentage points). A higher number means fewer but higher-quality trades. 5. **Configure sizing β max position % and Kelly fraction.** Max position % caps how much of capital any single trade can use. Kelly fraction scales bet size off the edge: 0.5 is **half-Kelly**, the most common choice because full Kelly (1.0) is mathematically optimal but brutally volatile. The engine takes the smaller of your max-position cap and the Kelly-derived size. 6. **Configure exits β stop-loss % and take-profit %.** These bound how far a position can move against you (stop) or in your favor (target) before it closes. They shape the size of individual wins and losses, which in turn drives your drawdown profile. 7. **Choose your lookback window.** Pick **30 days**, **90 days**, or **180 days** of simulated history (longer 1-year runs are also available). Longer windows give more trades and more statistically trustworthy numbers; shorter windows show you recent-regime behavior. 8. **Click Run.** Results render in about half a second.
For the **replay widget**, the flow is similar but you additionally paste a **Market ID** (a Polymarket condition ID like `0x1a2b...` or a Kalshi ticker like `PRES-2028`), pick a window (7β90 days), and set your dollars-per-trade. Leave the Market ID blank and it falls back to the Monte Carlo path.
## Reading the Results
After a run, the engine surfaces four headline metrics in large cards, then a second row of supporting stats, then visualizations.
### The four numbers that matter most
- **Total Return (%)** β the percentage gain or loss on starting capital over the window. Green is positive, red is negative. This is the headline, but never read it alone.
- β’**P&L ($)** β absolute dollar profit or loss. Useful for gut-checking whether the strategy is worth your time at your real capital level.
- β’**Win Rate (%)** β share of closed trades that made money. **Do not over-weight this.** A 45% win rate can be highly profitable if winners are larger than losers, and a 70% win rate can lose money if the losers are huge. Always pair it with P&L.
- β’**Sharpe Ratio** β return per unit of volatility, annualized (the engine annualizes daily returns by β252). This is the single best one-number quality score. As a rough guide: **below 1.0 is weak, 1.0β2.0 is solid, above 2.0 is excellent** for prediction-market strategies. A strategy with lower total return but a much higher Sharpe is often the better one to trade because it's smoother and easier to size up.
### The supporting stats
- **Total Trades** β your sample size. Fewer than ~20 trades means the other numbers are noisy; treat them as directional, not gospel.
- β’**Max Drawdown (%)** β the largest peak-to-trough drop in equity during the run. This is your pain number. Ask honestly: *would I have kept trading through a drawdown this deep without panicking?* If max drawdown is 35% and you'd bail at 20%, the strategy isn't viable for you regardless of its return.
- β’**Average Hold (days)** β how long positions stay open. This tells you the cadence: a 3-day average is active management; a 12-day average is patient.
### Outcome distribution and the trade log
- The **Equity Curve** plots account value over the window. You want a curve that grinds up-and-to-the-right. A curve that spikes early then bleeds, or one with a single huge cliff, is a warning even if the endpoint is positive.
- β’**Monthly Returns** break P&L into per-month buckets. Consistency matters: a strategy that makes money in 5 of 6 months is more trustworthy than one that owes its entire return to a single lucky month.
- β’The **Trade Log** lists individual trades with side (YES/NO), entry, exit, size, P&L, hold time, and result. Read your **best and worst trades** specifically β if your whole return came from one outlier, you don't have an edge, you have a coincidence.
- β’Use **Export CSV** (top-right of the trade log) to pull *all* trades β not just the last 10 shown β into a spreadsheet for deeper audit. CSV fields are sanitized against formula injection, so it's safe to open directly in Excel or Sheets.
## Tips for Trustworthy Backtests
- **Change one variable at a time.** Because Monte Carlo is deterministic, you can isolate the effect of, say, Kelly fraction by holding everything else constant. Sweep 0.25 / 0.5 / 1.0 and watch how Sharpe and max drawdown move together.
- β’**Optimize for Sharpe and drawdown, not raw return.** It's easy to crank return by sizing up; it's hard to do it without blowing up drawdown. The best-looking total return is rarely the best strategy.
- β’**Demand a real sample.** Push the window to 90 or 180 days so you have enough trades. A profitable 30-day run on 8 trades is not evidence.
- β’**Cross-check Monte Carlo against replay.** If a strategy looks great in Monte Carlo, validate the same logic on a real market's history via the replay widget. Agreement between the two is a strong signal; disagreement means dig deeper.
- β’**Match the backtest to how you'll actually trade.** Use your real capital, your real position caps, and exit rules you'll genuinely honor. A backtest of a disciplined strategy you won't follow is worthless.
## Gotchas and Limits
- **Backtests are directional, not prophecy.** Both engines are explicitly labeled as approximations. Monte Carlo uses historical *statistics*, not a replay of every real trade; the replay engine uses cached snapshots and a single-position-at-a-time model. Past performance does not guarantee future results β the standard caveat is true here for real reasons.
- β’**Replay needs data to exist.** The replay engine requires at least **10 snapshots** for a market, and ideally 50+ across at least a full day, before it returns useful output. On a fresh deployment or a thinly-covered market you'll see a `data_quality: insufficient` or `limited` warning. The fix is simply time β let the snapshot crons accumulate history.
- β’**Low trade counts carry warnings.** If fewer than 3β5 trades close, the engine flags high variance directly in the notes. Believe the flag.
- β’**Over-fitting is the cardinal sin.** If you tune parameters until the curve is flawless, you've memorized historical noise, not found a durable edge. A strategy that survives several different windows and a slightly different config is far more credible than one that's perfect on exactly one setting.
- β’**Rate limit.** Backtests are capped at **10 runs per hour per user** because each replay can scan thousands of snapshots. Plan your parameter sweeps rather than spamming Run.
## Plan Requirements
The Backtesting Engine is available on the **Pro ($59/mo)** and **Bot ($99/mo)** plans. It is **not** included on Starter ($29/mo) β Starter users will see an upgrade gate on /dashboard/backtest.
Backtesting itself never touches real money, so Pro is enough to use every feature on this page. To then **deploy a validated strategy as a live automated bot** trading on the Polymarket CLOB, you'll need the **Bot plan**, which unlocks the Bot Builder and live execution. The recommended path is: backtest on Pro or Bot β paper trade the survivors β go live on Bot.
## How It Connects to the Rest of Predite
Backtesting sits in the middle of a validation pipeline. The strategies you test here mirror the conditions used by the [EV Scanner](/docs/ev-scanner) and the Bot Builder, so a config that performs well in backtest translates almost directly into a live bot rule set. Once a strategy clears backtesting, the natural next step is to forward-test it risk-free in [Paper Trading](/docs/paper-trading) before committing capital. For sizing the positions your backtest assumes, the [Kelly Calculator](/docs/kelly-calculator) uses the same half-Kelly logic the engine applies internally. And when you're ready to automate a proven edge, the [Bot Strategies](/docs/bot-strategies) library lets you wire those exact rules into a continuously-running bot.
## Related Docs
- [How the EV Scanner Works](/docs/ev-scanner)
- β’[Paper Trading Guide](/docs/paper-trading)
- β’[Kelly Position Sizing](/docs/kelly-calculator)
- β’[Bot Strategies](/docs/bot-strategies)