On This Page
Key Takeaways
- Specify signals, decision times, eligible universe, position sizes, exits, execution and data handling so the experiment can be reproduced.
- Look-ahead bias and survivorship bias can create profits that were not available to a real trader at the time.
- Out-of-sample and walk-forward tests protect information that was not used to select the rules.
- Count each applicable cost once. Costs embedded in simulated fill prices must not also be deducted as separate charges.
- Compare net return, drawdown, turnover and nearby parameter settings on the selected development and test windows.
What is backtesting?
Backtesting is the practice of applying fully specified trading or investment rules to historical data to estimate how those rules would have behaved in the past. A test specifies the universe, signal, decision time, order, position size and exit, then calculates the resulting account record. The output is the rules’ record on past data, the first evidence to weigh before they trade real money.
Each input must have been available at its historical decision time. Use the relevant data vintage, contract specification, corporate-action treatment and universe membership for that date.
How a backtest handles signal timing and execution costs
Separate the information timestamp, decision timestamp, order submission and fill. A signal requiring the final close becomes available after that close is determined; an order submitted before the close must use information already available then.
Model the applicable spread, execution delay, fees, financing and borrow. For options, include quote availability, contract changes, exercise, assignment and the defined treatment of positions at expiry.
If a simulated fill already crosses the bid-ask spread, do not deduct that same spread cost again. Keep the reference price and each additional execution-cost term explicit in the accounting.
Formula
Net simulated P&L = gross simulated P&L − applicable costs not already included in the simulated fills. For a fixed starting capital and no external cash flows, total return = net P&L / starting capital.- Keep P&L and costs in the same currency. Apply commissions, fees, financing, borrow and execution costs according to the position and fill convention, without double counting.
- Measure performance through drawdown, exposure, turnover and the outcome distribution as well as return.
Backtest example: costs on 240 round trips
A daily strategy generates 240 historical round trips with $18,600 gross profit. Modeled commissions and fees are $720, spread cost is $1,440, and slippage is $2,160.
- $720 + $1,440 + $2,160 = $4,320 modeled trading costs
- $18,600 − $4,320 = $14,280 net simulated profit
- $4,320 / 240 = $18 average modeled cost per round trip
The 240 round trips produce $14,280 net simulated profit. Total modeled cost is $4,320, or $18 per round trip and 23.2% of gross profit. Compare this net result with the same accounting applied to the test period.
To state the $14,280 as a return, subtract costs in dollars first, then divide by the capital the strategy committed.
In-sample development vs out-of-sample testing
Use the development period to select the procedure. Freeze that procedure before evaluating the reserved test data. A fixed-rule holdout tests one frozen rule set on one reserved window, while walk-forward refits on the past and tests each next segment.
For walk-forward evaluation, fit on the available past and evaluate the next segment. Train only on outcomes already settled by each cutoff; rolling indicators set in advance update bar by bar through the test, as they would live.
Record net return, drawdown, expectancy, turnover, exposure and concentration. Compare with a benchmark using the intended capital and risk exposure.
Forward evaluation after a backtest
Check the live data feed, signal generation, orders and position accounting. Compare realized fills and costs with the specified execution process.
Preserve the code, configuration and input versions needed to reproduce each research result. Evaluate any redesigned version on data reserved for that version.
Limitations of backtesting
- A backtest replays fixed rules on one historical path, and markets, liquidity and costs change. Prove the record on reserved data and in a small forward test before trading full size.
- Use point-in-time data. Data errors can create profits no trader could have earned: look-ahead bias uses information before it was available, and survivorship bias drops delisted and failed securities from the universe.
- Check nearby parameter settings and count the variations tested. Testing many variations on the same history raises the chance of fitting noise, and a result that holds at only one parameter setting, or fades on the reserved test period, points to overfitting.
- Stress the fill assumptions. Simulated fills assume the modeled spread, delay and size were available, and thin markets, wide option quotes and the strategy’s own orders can make real fills worse than the model.
- Build a large enough trade sample before sizing on the results. A small number of trades leaves wide uncertainty around net return, win rate and drawdown.
Bottom line
Backtesting turns a trading idea into a reproducible experiment on historical data. Use it to measure net return, drawdown and costs with point-in-time data and realistic fills, then judge the frozen rules on reserved data and in forward evaluation before trading them at full size.
Clear answers
Frequently Asked Questions
Sources and Further Reading
- CFA Institute: Backtesting and Simulation
- CFA Institute Research Foundation: Investment Model Validation
How entries are sourced, calculated and updated: editorial methodology.