Home / Wiki / B / Backtesting

Backtesting

Trading and SpeculationUpdated 13 Nov 2026

Backtesting is the practice of applying a trading or investment strategy to historical market data to see how it would have performed. A trader writes down precise rules for when to buy, sell and size positions, runs those rules over past prices, and studies the simulated results: returns, losses, volatility and the number of trades. The aim is to reject weak ideas cheaply before committing real money.

Backtesting is a core tool in quantitative finance and algorithmic trading, and it is widely used by retail traders through charting platforms and by crypto traders who configure trading bots. Banks also use the word for a regulatory exercise: comparing value-at-risk forecasts with actual losses. In both senses the method is only as good as the data and assumptions behind it, and a strong backtest is no guarantee of future results.

01

Backtesting in plain terms

Imagine you have a new rule for carrying an umbrella: take one whenever the morning sky is grey and the wind is from the west. Before trusting it, you could look back through a year of weather diaries and check how often the rule would have kept you dry, and how often you would have carried an umbrella for nothing.

Backtesting a trading idea is the same exercise with price records instead of weather diaries. It tells you how a rule behaved in the past. It cannot tell you whether the weather, or the market, will behave the same way next year, and if you keep tweaking the rule until it fits last year perfectly, you may simply have memorised last year.

02

How a backtest is run

A careful backtest normally follows these steps:

  1. Define the rules. Entry and exit signals, position size, stop-losses and the markets traded are written down so they can be applied mechanically.
  2. Gather clean data. Prices, volumes and, where relevant, dividends, splits, funding rates and delisted assets are collected for a long enough period to cover several market conditions.
  3. Model costs. Commissions, the bid-ask spread, slippage and borrowing costs are deducted, since they can turn a profitable strategy into a losing one.
  4. Simulate trades. Software steps through the data in time order, using only information available at each moment.
  5. Review results. The trader studies return, risk and consistency, then tests the rules on a separate period of data not used in development.
03

Measuring a backtest

Common outputs include total and annualized return, maximum drawdown (the largest fall from a peak), win rate, average gain and loss per trade, and risk-adjusted measures such as the Sharpe ratio. Traders also look at how many trades the result rests on, because a strategy that made money from five trades is far less convincing than one tested over five hundred. Comparing the result with a simple benchmark, such as buying and holding the same asset, shows whether the rules added anything.

04

Common pitfalls

Backtests are easy to fool. The main dangers are:

  • Overfitting. Adjusting parameters until the past looks perfect produces rules that capture random noise rather than a real pattern.
  • Look-ahead bias. Using data that would not have been known at the time, such as a closing price to trigger a trade at the open, inflates results.
  • Survivorship bias. Testing only assets that still exist today ignores companies that went bankrupt or coins that were delisted, a form of survivorship bias that is especially severe in crypto.
  • Ignoring market impact. A strategy that trades large amounts in thin markets would move prices in reality, which a simple simulation does not capture.
  • Regime change. Rules built in a long bull market may fail in a bear market or a period of very different volatility.

To reduce these risks, practitioners use out-of-sample testing, walk-forward analysis (repeatedly developing on one window and testing on the next), and paper trading before going live.

05

Backtesting in risk management

Under the Basel framework, banks that use internal models for market risk must backtest their value-at-risk estimates. They count the days on which actual trading losses exceeded the model's forecast. Too many such exceptions in a year signals that the model underestimates risk, and supervisors can require higher capital. The Basel Committee set out a traffic-light approach to this test in the 1990s, and later reforms kept backtesting as a condition for using internal models. Insurers, asset managers and central counterparties run similar checks on margin and stress models.

06

Backtesting in crypto markets

Crypto traders backtest strategies for spot trading, perpetual futures and automated bots offered by exchanges. The market's short history, frequent outages, extreme moves and fragmented liquidity across venues make results less reliable than in mature markets. Data quality is a particular issue: prices can differ widely between exchanges, many tokens have only a few years of history, and wash trading has inflated reported volumes on some venues. Marketing that shows impressive backtested returns for a bot or signal service should be treated with caution, since the results are hypothetical and often heavily optimised.

Last updated 13 Nov 2026