TradeLabs AILearn

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.

Intermediate3 min readUpdated 3 Oct 2026
Markdown
Lesson 4 of 38

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#

  1. Define the rules precisely: entries, exits, position sizing and risk limits, with no room for interpretation.
  2. Prepare data: clean, adjusted for corporate actions, free of survivorship bias, with correct timestamps. See Historical Data for Backtesting.
  3. Simulate trading through time, using only information available at each moment.
  4. Apply costs and realistic fills. See Costs and Slippage in Backtests and Fill Models, Partial Fills and Order Queues.
  5. Calculate performance metrics.
  6. Validate out of sample and test robustness. See In-Sample vs Out-of-Sample Testing.
  7. Document everything for reproducibility. See Backtest Reproducibility.

Key performance metrics#

MetricWhat it showsLesson
Total and annual return (CAGR)GrowthMeasuring Returns and CAGR
VolatilityVariability of returnsVariance and Standard Deviation
Sharpe and Sortino ratiosReturn per unit of riskSharpe Ratio, Sortino Ratio
Maximum drawdownWorst peak to trough lossMaximum Drawdown
Win rate and payoff ratioTrade level behaviourWin Rate and Payoff Ratio
Profit factorGross profit / gross lossProfit Factor
Number of tradesStatistical reliabilityStatistical Significance in Trading
Turnover and costsTrading intensitySignal Turnover, Breadth and Neutralization
ExposureTime and capital in the market

Event driven vs vectorised backtests#

ApproachHow it worksProsCons
VectorisedCalculate signals and returns for all dates at once with arraysFast, simpleHarder to model complex order logic; easier to introduce look ahead bias. See Event-Driven vs Vectorized Backtesting
Event drivenProcess data one event at a time, as in live tradingRealistic; same code can run liveSlower, more complex

Avoiding biases#

BiasPrevention
Look ahead biasLag signals; use point in time data. See Look-Ahead Bias
Survivorship biasInclude delisted securities. See Survivorship and Selection Bias
Data snoopingLimit variations; record all tests. See P-Hacking and Multiple Testing
OverfittingFew parameters; robustness tests. See Overfitting and Curve Fitting
Unrealistic executionConservative costs and fill assumptions

A backtest checklist#

  1. Are rules fully specified before testing?
  2. Is every input available at the time of each decision?
  3. Does the universe include delisted and failed securities?
  4. Are costs, slippage and borrowing included, conservatively?
  5. Is position sizing realistic relative to liquidity?
  6. How many variations were tested?
  7. Does it hold out of sample and across periods and markets?
  8. Are results driven by a few trades or one period?
  9. 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.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonHistorical Data for BacktestingBacktests are only as good as their data. Learn data types and sources, quality checks, corporate action adjustments and how to avoid survivorship traps.

Mentioned in