Research and portfoliosStrategy Research

Backtest

On this page

In brief

Applying a written trading rule to historical data to simulate fills, costs and performance using information available at each decision.

What inputs does a backtest need?

Specify the rules, trading universe, data frequency, signal time and fill time. If a weekly signal uses the final session’s close, simulate execution only after that close is available. Record how order types, halts and missing values are handled so the equity curve does not include impossible fills.

In a simple ledger, record gross profit or loss, spreads, commissions and slippage. Aggregate to net return and compare it with a benchmark over the same period. If hypothetical gross profit is 120 units and fill costs total 50, net profit is 70. Recalculate with higher costs to see how sensitive the rule is to execution.

How do you make a backtest reproducible?

Preserve the data source and version, parameters, sampling frequency, information availability and trade ledger. Report the test dates, maximum drawdown, trade count and unfilled orders. A few exceptional trades can dominate a curve, so the ledger explains what happened more clearly than a return chart alone.

Testing many variants increases the chance of selecting one with a strong historical result by luck. Log the candidate rules, set evaluation metrics in advance and reserve out-of-sample data for evaluation. Check for look-ahead bias, such as using a revision unavailable on the original signal date.

From research code to a reproducible experiment

Keep information availability, order submission and execution times separate. A signal computed from the closing price cannot execute at that day’s opening price. Even a next-bar assumption needs a valid trading session and executable price. Store both data and trade timestamps, then hand-check selected observations to catch timing errors that do not produce a software exception.

Execution assumptions should match the strategy. Slow allocation rules and rapid order strategies have different sensitivities. Assuming every touched limit fills completely can overstate fills; using midpoints for every trade can understate costs. Start with a transparent model, vary the assumptions and report sensitivity. Complexity alone does not establish realism.

Preserve the full search trail. Showing one winner from a hundred attempts hides selection. Log parameters, dates, windows and metrics for unsuccessful versions too. Changes prompted by results start another development cycle requiring fresh validation. Neighbourhood plots can reveal sensitivity, but they do not replace genuinely unused observations.

Ask a classmate who did not write the code to rerun the study from documented data, cleaning rules, entry point, costs, seeds and outputs. Retain the chain from signal to order, fill, position and cash. Investigate discrepancies before debating the strategy. An unsupported or unsuccessful rule is still a valid research result when the experiment is reproducible.

The GUTL perspective

A backtest is a rule-bound historical experiment. Preserve data versions, parameters, costs and unfilled orders so a classmate can reproduce it.

Everyday example

Testing staff schedules on old cafeteria traffic must use information known before each shift, not hindsight about the busiest hours.

Simulation example

Specify the weekly signal and execution time before simulating a historical period. Retain unfilled orders and validate on a separate period.

Does a high backtested return predict future performance?

A backtest shows what a specific rule would have done under particular data and fill assumptions. Held-out evaluation, cost sensitivity and alternative scenarios help establish the scope of the result. Future performance can differ.

Student comments

Further reading

3 articles