Backtesting Methodology
A backtest simulates a strategy on historical data. Learn the steps, the key performance metrics, common biases and a checklist for backtests you can trust.
A backtest simulates how a trading strategy would have performed on historical data. It is the main tool for evaluating ideas before risking money. Done carefully, backtesting filters out bad ideas and gives a realistic sense of what to expect. Done carelessly, it produces impressive numbers that mean nothing. The difference lies in methodology: clean data, realistic assumptions, honest validation and awareness of the many biases that can creep in.
The steps of a backtest#
- Define the rules precisely: entries, exits, position sizing and risk limits, with no room for interpretation.
- Prepare data: clean, adjusted for corporate actions, free of survivorship bias, with correct timestamps. See Historical Data for Backtesting.
- Simulate trading through time, using only information available at each moment.
- Apply costs and realistic fills. See Costs and Slippage in Backtests and Fill Models, Partial Fills and Order Queues.
- Calculate performance metrics.
- Validate out of sample and test robustness. See In-Sample vs Out-of-Sample Testing.
- Document everything for reproducibility. See Backtest Reproducibility.
Key performance metrics#
| Metric | What it shows | Lesson |
|---|---|---|
| Total and annual return (CAGR) | Growth | Measuring Returns and CAGR |
| Volatility | Variability of returns | Variance and Standard Deviation |
| Sharpe and Sortino ratios | Return per unit of risk | Sharpe Ratio, Sortino Ratio |
| Maximum drawdown | Worst peak to trough loss | Maximum Drawdown |
| Win rate and payoff ratio | Trade level behaviour | Win Rate and Payoff Ratio |
| Profit factor | Gross profit / gross loss | Profit Factor |
| Number of trades | Statistical reliability | Statistical Significance in Trading |
| Turnover and costs | Trading intensity | Signal Turnover, Breadth and Neutralization |
| Exposure | Time and capital in the market |
Event driven vs vectorised backtests#
| Approach | How it works | Pros | Cons |
|---|---|---|---|
| Vectorised | Calculate signals and returns for all dates at once with arrays | Fast, simple | Harder to model complex order logic; easier to introduce look ahead bias. See Event-Driven vs Vectorized Backtesting |
| Event driven | Process data one event at a time, as in live trading | Realistic; same code can run live | Slower, more complex |
Avoiding biases#
| Bias | Prevention |
|---|---|
| Look ahead bias | Lag signals; use point in time data. See Look-Ahead Bias |
| Survivorship bias | Include delisted securities. See Survivorship and Selection Bias |
| Data snooping | Limit variations; record all tests. See P-Hacking and Multiple Testing |
| Overfitting | Few parameters; robustness tests. See Overfitting and Curve Fitting |
| Unrealistic execution | Conservative costs and fill assumptions |
A backtest checklist#
- Are rules fully specified before testing?
- Is every input available at the time of each decision?
- Does the universe include delisted and failed securities?
- Are costs, slippage and borrowing included, conservatively?
- Is position sizing realistic relative to liquidity?
- How many variations were tested?
- Does it hold out of sample and across periods and markets?
- Are results driven by a few trades or one period?
- Can someone else reproduce the results from your code and data?
Interpreting results#
A backtest is a hypothesis about the future, not a promise. Treat headline numbers as optimistic upper bounds and focus on robustness, drawdowns and the range of plausible outcomes. Monte Carlo resampling helps show that range. See Monte Carlo Simulation.
Frequently asked questions#
What is backtesting?#
Simulating a trading strategy on historical data to estimate how it would have performed.
What makes a backtest reliable?#
Clean, point in time data without survivorship bias, precise rules, realistic costs and fills, few tested variations, and validation on data not used to build the strategy.
Is a good backtest enough to trade a strategy?#
No. Backtests are usually optimistic; strategies should also pass out of sample tests, robustness checks and small live trading.
Next, learn how to choose and prepare data in Historical Data for Backtesting.
3 quick questions on this lesson. Get them all right to finish it.
Turn on JavaScript to take the quiz.
Mentioned in
- The Trading Research ProcessResearch and Backtesting
- Why Strategies FailResearch and Backtesting
- Quant Trading Learning PathStart Here
- Reading Academic PapersStart Here
- Recency BiasTrading Psychology
- Discretionary vs Systematic TradingStrategies and Styles