Backtesting means testing an investment strategy against historical data to see how it would have performed. Before you commit real money to an idea — buy quality stocks when they get cheap, say, or follow momentum — you can ask decades of market history what happened to investors who did exactly that.
A backtest turns a hunch into numbers: the strategy's returns, its worst stretches, how consistent it was across different markets. That's valuable, with one caution that belongs in every conversation about backtesting: the past is evidence, not a promise. A strategy that would have worked beautifully for thirty years can still fail for the next five. A good backtest raises your confidence that an idea is sound. It never guarantees a result, and anyone who says otherwise is selling something.
A single-ticker backtest evaluates a strategy on one stock — for example, buying when RSI drops below 30 and selling when it rises above 70. It's useful for learning, but it's limited, because real investing almost never means one stock in isolation.
A portfolio-level backtest evaluates a strategy across a whole universe of stocks at once, simulating the actual experience of running a portfolio: which stocks the rules select, how much goes into each position, when the portfolio rebalances, what happens to spare cash, and what trading costs eat along the way. Well Street's backtester works at this level, testing your rules against decades of history the way a real portfolio would have lived them.
The difference matters because portfolios behave differently than their parts. Diversification, allocation, and rebalancing decisions can matter as much as the buy signal itself.
Overfitting is the most dangerous trap in backtesting. It means tuning a strategy so precisely to historical data that it captures the noise of that particular past rather than a real, repeatable pattern. Overfit strategies look spectacular in the test and then quietly die in live markets.
Here's how it happens. You test a moving-average rule. 50 days doesn't impress, so you try 48, then 53, then add a volume filter, then an exception for Decembers. After enough tweaking, you find a combination with a gorgeous track record. But you didn't discover a market truth — you reverse-engineered one specific history. There were thousands of possible rule combinations, and you kept the one that happened to fit.
Warning signs: many finely tuned parameters, results that collapse when a parameter shifts slightly, and rules you can't explain economically. A robust strategy usually has a simple story for why it should work — and keeps working, roughly, when you nudge its settings.
The classic defense against overfitting is to never let a strategy grade its own homework. Split history in two. The in-sample period is where you develop and tune the strategy — say, 2000 through 2014. The out-of-sample period — 2015 onward — is held back, untouched, until the design is frozen. Then you run the strategy on the data it has never seen. If performance holds up, that's real evidence. If it collapses, you were probably fitting noise.
Walk-forward analysis repeats this on a rolling basis: tune on a window of years, test on the next stretch, slide forward, and repeat. It mimics how you'd actually run a strategy through time.
One rule keeps the whole thing honest: you only get to use out-of-sample data once. Peek at it, adjust the strategy, and test again — and it silently becomes in-sample data. Every retest after a peek is a little less trustworthy.
On paper, trades are free and instant. In reality, every trade pays a toll, and backtests that skip the tolls flatter themselves.
The costs come in layers. Commissions are the visible part, and often small now. The bid-ask spread is subtler: you buy at the ask and sell at the bid, losing the gap each round trip. Slippage is the price drifting between your signal and your fill, and it grows with order size and shrinks with liquidity.
The damage scales with how often you trade. Suppose a strategy turns over its whole portfolio monthly and pays 0.2% per round trip in spread and slippage. That's roughly 2.4% a year — enough to turn a market-beating backtest into a market-trailing reality. A slow, quarterly strategy might barely notice the same toll. When you read any backtest, ask whether costs were modeled, and at what assumed rate. If the answer is no, mentally shave the results.
Most people read a backtest by looking at one number: the compound annual growth rate. That's the least useful place to stop.
Start instead with maximum drawdown — the deepest peak-to-trough loss along the way. Two strategies can both show a 12% CAGR while one dipped 20% at its worst and the other fell 55%. They are not remotely the same investment, because the second one would have tested you brutally. A 55% drawdown needs a 122% gain just to break even, and most investors bail somewhere near the bottom. The best strategy on paper is worthless if you can't hold it through its worst year.
Then widen the lens. How long was the test — does it include 2008 and 2022, or only calm years? Did the strategy win across different periods, or did one lucky stretch carry everything? Was the data point-in-time and survivorship-free? Were costs included? A backtest read this way tells you something real. Read as a single shiny return number, it mostly tells you what you want to hear.
Previous: Point-in-Time Analytics · Next: Portfolio Construction · Financial glossary
← Back to all investing concepts