Trading · Advanced

How to Backtest a Trading Strategy Properly (Without Fooling Yourself)

April 25, 20268 min readpoly-sim.com

Backtesting is testing a trading strategy against historical data to evaluate its performance. Done correctly, it builds genuine confidence in your edge. Done incorrectly (as most retail traders do it), it creates false confidence in strategies that will fail in live trading. The most important skill is avoiding overfitting.

The Overfitting Trap

Overfitting is when you optimise a strategy so precisely to past data that it captures noise rather than genuine signal. An overfitted strategy looks incredible in backtests and immediately fails in live trading because the specific patterns it learned don't persist.

Warning signs your backtest is overfit:

The Right Way to Backtest

Step 1: Split Your Data

Divide historical data into in-sample (training) data and out-of-sample (test) data. Develop your strategy exclusively on the in-sample data. Test it only once on the out-of-sample data. If you keep peeking at out-of-sample data to refine the strategy, it becomes in-sample — start over.

Step 2: Walk-Forward Testing

More robust than simple train/test split. Develop on a rolling window of past data, test on the immediate subsequent period, roll forward, repeat. Simulates real-world trading conditions more accurately than static splitting.

Step 3: Realistic Costs

Include trading fees, slippage, and spread in your backtest. A strategy that generates 2% annual returns before fees but costs 3% in fees is actually losing money. Use realistic slippage estimates (0.1-0.3% per trade in liquid markets).

Step 4: Sample Size

Need at minimum 100 trades in your backtest for statistical significance. 200-300 trades is more reliable. Any strategy evaluated on fewer than 50 trades is not statistically meaningful.

💡 Paper Trading Before Live

After a promising backtest, paper trade (simulated live trading) for at least 30 trades before risking real capital. Paper trading reveals execution issues (order fills, timing) that backtests miss. If the paper trading results are broadly consistent with the backtest (accounting for randomness), you have genuine confidence to go live with minimal risk sizing.

Key Backtesting Metrics Explained

A backtest produces many numbers. Here are the ones that actually matter:

Common Backtesting Biases

Look-Ahead Bias

Using information that wouldn't have been available at the time of the trade. For example, entering a trade based on a daily candle's close when you would have had to trade mid-candle in real-time. Even subtle forms are common: using the opening price of a bar to fill an order that triggers on that bar's data.

Survivorship Bias

Testing only on assets that still exist today, ignoring those that crashed to zero or were delisted. This creates inflated performance because every asset in your backtest survived. In crypto, hundreds of tokens from 2020–2022 no longer exist. A strategy that performed well on "all 2020 crypto" is not comparable to what you'd have experienced trading randomly chosen 2020 tokens.

Execution Bias

Assuming perfect fills — that your orders always execute at exactly the signal price, immediately, with no slippage. In reality, limit orders may not fill; market orders have slippage; thin markets have wide spreads. Add realistic execution costs (0.1–0.3% per trade in liquid markets) before evaluating any strategy.

Selection Bias

Testing only on the assets or time periods where you know the strategy worked. Every strategy looks good if you cherry-pick its best environment. A robust strategy works across multiple assets, time periods, and market conditions — not just the ones in your training sample.

Backtesting Prediction Market Strategies

The backtesting principles apply equally to prediction market strategies, with adaptations for the market structure:

🔬 Prediction Market Backtesting Shortcut

Polymarket's historical data is available via their API and community data exports. Track how well simple rules perform over 100+ markets: e.g., "Buy any market between 20–30% that has shown a 10-point upward move in the past 24 hours." Building even a simple spreadsheet of 50 historical trades with your entry rule applied consistently is more valuable than reading 10 trading books.

← Mean Reversion Sentiment Analysis → All Trading Articles
🎯
Test Your Strategy Live on Polymarket
Once you've validated your edge through backtesting, put it to work in real prediction markets.
Open Polymarket →