To backtest a trading strategy, write the rule down before you look, run it on data as it was known at the time, charge realistic costs, keep some history back to test on, read the results with the drawdowns in view, and record what you decided and why.
1. Write the rule down first
A backtest tests a rule, so the rule has to exist before the test: what you buy, when, how much, and when you sell. Written in advance, it cannot quietly bend to fit the history you are about to look at.
2. Use data as it was known at the time
The most common way a backtest misleads is by using information that did not exist yet. Companies restate figures, and many databases keep only the latest version, so a test that reads today’s restated number on the date of the original report is seeing the future. The same goes for companies that no longer exist: a list of today’s index members leaves out the ones that failed, and the past looks better than it was.
Each figure should carry the date it became public, not only the period it describes.
3. Charge realistic costs
Commissions, the spread between the buying and selling price, and the price moving against a large order all come out of returns. A strategy that trades often can look excellent before costs and lose money after them.
4. Keep some history back
Build the rule on one stretch of history and test it on another it has never seen. Repeating that through time — build on one period, test on the next, then move both forward — shows whether the rule keeps working or only fitted the past.
5. Read the results honestly
- Drawdown. The worst fall from a peak, and how long it lasted. This is what you would have lived through.
- Return for the risk taken, not return alone.
- Number of trades. A handful of trades proves little.
- Sensitivity. If the result only works at one exact setting, it has probably fitted noise.
6. Record what you decided, and why
A backtest tests the rule. It does not tell you, a year later, why you switched it on, what you believed at the time or what you knew. Write that down when you decide: the rule, the evidence, the result you expected and the risk you accepted. It is the only way to learn from the live result rather than argue with it.
Mistakes that flatter results
- Look-ahead: using a figure before it was published.
- Survivorship: testing only on companies that still exist.
- Overfitting: tuning the rule until it matches the past.
- Ignoring costs.
- Too little history, or only one kind of market.
Where Quantify Terminal fits
We build Quantify Terminal, and its focus is the record around a decision. Every figure in its Data Fabric carries the time it became knowable, so research reads what was known then rather than what was published later. Every decision is recorded with the rationale, the evidence cited and the model and thesis version on screen, and Replay reads that state back, so a year later the reasoning can be checked against what happened.
It is in early access for funds and investment teams, by application. See the product.
Frequently asked questions
How much history do I need to backtest?
Enough to include different kinds of market and enough trades to mean something. A few years of daily data is a minimum for most strategies, and more for slow ones.
What is overfitting?
Tuning a rule until it fits the past so closely that it has learned the noise. It shows up as a result that falls apart when the settings move slightly or when it is tested on new data.
Can I backtest without coding?
Yes. Spreadsheets work for simple rules, and many platforms let you describe a rule without writing code. Code helps once the rule or the data gets complicated.
What is walk-forward testing?
Building the rule on one period and testing it on the next, then moving both forward, so every result comes from data the rule had not seen.