Backtesting

Walk-Forward Optimization for Prediction Market Strategies

How to use walk-forward optimization to validate trading strategies on Polymarket historical data and avoid overfitting.

What Is Walk-Forward Optimization?

Walk-forward optimization (WFO) is a technique for validating trading strategies that avoids the overfitting trap of traditional backtesting. Instead of optimizing parameters on all historical data at once, WFO divides the data into sequential train/test windows and optimizes on each training window, then tests on the subsequent out-of-sample period.

Why WFO Matters for Prediction Markets

Prediction markets have evolving dynamics — liquidity patterns change, new market makers enter, and market microstructure shifts over time. A strategy optimized on 30 days of historical data may not work on the next 30 days. WFO catches this by testing on truly out-of-sample data from PolyHistorical.

Walk-Forward Process

StepActionData Window
1Optimize parameters on training dataDays 1-10
2Test optimized parameters out-of-sampleDays 11-13
3Slide the window forwardDays 4-13 (train), Days 14-16 (test)
4Repeat until all data is usedContinue sliding...
5Concatenate all out-of-sample resultsAll test periods combined

Key Parameters to Decide

  • Training window size: How many days/hours of data to optimize on (e.g., 7-14 days)
  • Testing window size: How long to test each set of optimized parameters (e.g., 2-3 days)
  • Slide step: How far to move the window each iteration (typically equal to test window)
  • Optimization metric: What to optimize for — Sharpe ratio, profit factor, or total return

Implementation with PolyHistorical Data

PolyHistorical's 30-day rolling history for each market provides enough data for meaningful WFO. Here is a practical approach:

  • Pull 30 days of order book history for your target market
  • Use 10-day training windows with 3-day test windows
  • Optimize your strategy parameters (e.g., lookback period, z-score threshold) on each training window
  • Apply the optimized parameters to the test window and record results
  • Concatenate all test-window results for your true out-of-sample performance

Interpreting WFO Results

The concatenated out-of-sample results give you a realistic estimate of strategy performance. Key things to check:

  • Is the out-of-sample Sharpe ratio positive and stable across windows?
  • Do optimal parameters change dramatically between windows (sign of overfitting)?
  • Is there degradation in performance over time (sign of changing market dynamics)?
  • Are the results consistent across different market types (BTC vs ETH, different timeframes)?

Common Pitfalls

  • Too many parameters: More parameters = higher overfitting risk, even with WFO
  • Look-ahead bias: Ensure your training window does not use any future data
  • Survivorship bias: Include markets that have already resolved, not just active ones
  • Too short training windows: Insufficient data for reliable parameter estimation

Related Resources