Backtesting
- Category
- Algorithmic Trading
- Level
- Professional
Simple definition
Running a trading rule over past data to see what it would have done. It records a hypothesis rather than forecasting, and only counts if the rule was followable then.
Professional definition
Simulating a fully specified rule on historical prices, bar by bar, with every decision taken from information available at that bar, and with fees, spread, slippage and funding deducted. The output is an equity curve and a set of statistics describing one path through one sample.
Technical definition
A backtest is an experiment whose validity rests on three things: that signals use only information available before the trade, that fills are achievable against the liquidity that existed, and that the sample was not searched for the result being reported. Breaking the first makes the result void, not optimistic. Breaking the second inflates it by the size of the unmodelled cost. Breaking the third makes the statistics unmeasurable, because the reported path is the best of many unreported ones.
Academic definition
The historical simulation of a fully specified decision rule on past data, with returns computed net of transaction costs, used to estimate the distribution of outcomes the rule would have produced in the sample.
Mechanism
A backtest is a recursion over equity: each bar applies the position chosen before the bar to the return of the bar, then deducts the costs actually incurred. Every assumption in that recursion is an assumption about the past that cannot be verified from the equity curve itself, which is why the curve is evidence about the code as much as about the market.
In practice
- Who uses it
- Systematic strategy developers, quantitative researchers, risk reviewers, and discretionary traders formalising a rule.
- Why it matters
- It forces a vague idea into a complete specification: entry, exit, size, data source and cost model must all be written down before anything can run.
- Limitations
- Costs, funding and slippage are modelled, not observed, and modelling them optimistically is the most common way a profitable backtest becomes an unprofitable system. A single sample also gives one path, not a distribution.
Common mistakes
- Reporting results gross of fees, spread, slippage and funding.
- Treating the best of many parameter runs as the expected result.
- Testing on a universe that excludes instruments that later failed.
Examples
Two engineers code the same written rule. One fills at the signal bar's close, the other at the next bar's open with slippage. The rules are identical; the equity curves are not comparable.
Equity 10,000 and a bar return of 1.2 percent at full size, with 0.15 percent of costs charged in that bar, gives 10,105. The gross figure would have been 10,120: the gap is the cost model.
- E_{t-1} = 10,000
- w_{t-1} = 1 (fully invested, decided before the bar)
- r_t = 1.2 percent
- k_t = 0.15 percent of equity, covering fee, spread and slippage
- 1 + 0.012 - 0.0015 = 1.0105
- 10,000 x 1.0105 = 10,105
- gross comparison: 10,000 x 1.012 = 10,120
Illustrative figures. Repeated over hundreds of bars this 15 basis point difference compounds, which is why the cost model decides whether a backtest means anything.
Mathematical foundation
Variables
| E_t | Equity at the end of bar t | currency |
| w_{t-1} | Position weight chosen before bar t, as a fraction of equity; negative for short | fraction of equity |
| r_t | Return of the instrument over bar t | fraction |
| k_t | Costs charged in bar t as a fraction of equity: fees, spread crossed, slippage and any funding accrued | fraction |
| \mathcal{F}_{t-1} | The information set available before bar t begins | information set |
Procedure
Start from initial capital. For each bar in order, read the position decided from information available before that bar, apply the bar's return to it, subtract the period's costs, and carry the result forward. Never revisit an earlier bar once a later one has been read.
Worked example
- E_0 = 10,000
- w_0 = 1
- r_1 = 0.012
- k_1 = 0.0015
- 1 + 0.012 - 0.0015 = 1.0105
- E_1 = 10,000 x 1.0105
Interpretation
The recursion is the whole backtest. Its honesty lives in two symbols: the subscript on w, which must be earlier than the bar it trades, and k, which must contain every cost actually payable.
Assumptions
- Costs are charged as a fraction of equity in the bar in which they occur; a per-contract or per-share fee schedule needs converting before it fits this form.
- Position weight is set on information strictly before the bar it is applied to, which is the condition the lookahead-bias entry formalises.
- The instrument return is the return actually achievable, including any dividend, funding or roll convention relevant to the contract.
- The recursion describes a single realised path through a single sample. It is not an estimate of expected return and carries no confidence interval.
- It silently assumes orders of the simulated size were fillable at the modelled price, which for illiquid instruments is often false.
Related terminology
Walk-Forward Testing
A backtest is the simulation itself and can be run on all the data at once. Walk-forward testing is a protocol for arranging backtests so that each evaluation window was never used to choose the rule.
Sources
CMT Association · system design, testing and evaluation topics
https://cmtassociation.org/wp-content/uploads/2026/03/2026-CMT-Program-Guide_v2026.3.5.pdf URL verified
CMT Association · chapters on testing rule-based methods and the evidence they produce
https://cmtassociation.org/wp-content/uploads/2019/01/Technical-Analysis-Modern-Perspectives-CMT-Association.pdf URL verified
CFA Institute · principles of performance measurement net of costs
https://www.cfainstitute.org/insights/professional-learning/refresher-readings/2026/portfolio-performance-evaluation URL verified
Editorial status
Written, not yet reviewed.
