Backtesting Essentials · Lesson 3
Survivorship bias
Did the test only see the winners? Why testing on today's list of stocks leaves out the ones that died, and how much that flatters a result.
Know the basics? Read the lesson notesA backtest on today's list
A stock is a small share of a company, bought and sold on an exchange; its price moves every trading day. A backtest replays a plan over past prices to see what it would have made.
The plan: put $100 into every stock on a list at the start of 2015, and hold to the end of 2024. No trading costs. For the list, you take the stocks trading today (here, the end of 2024): 311 of them, each with prices going back to 2015. These are simulated stocks: prices made up by a program, not taken from any real market.
Today's 311 stocks, bought in 2015 and held (simulated)
The line: what $100 in the average stock on the list was worth on each day. Dotted line: the $100 put in.
On average, $100 became $284.71: a gain of $184.71 on each $100, or +184.7% over ten years.
Who is missing?
Today's list holds only the stocks still trading today. In 2015 there were more. Some stopped trading along the way: they were delisted, taken off the exchange. In real markets that happens when a company goes bust, its price falls too far, or another company buys it. In this simulation one rule decides it: a stock is delisted on the first day its price closes (its price at the end of the day) below a quarter of its 2015 price, so below $25 for each $100 put in. A holder gets that last price, and the stock is gone.
Press Play to watch all the stocks that traded in 2015, over the ten years.
Every stock trading in January 2015, ten years (simulated)
One line per stock: what its $100 was worth. The scale is stretched at the bottom, so low values stay readable: from $100 to $1,000 takes as much room as from $10 to $100 would. Dashed line: $25. A line that ends with an orange mark is a stock delisted there; it then fades.
500 stocks traded in 2015. 189 were delisted before the end of 2024. The 311 left are today's list. The 189 left no row on it, so the backtest you just ran never saw them.
Put them back: guess first
On today's list, $100 became $284.71 on average. Now run the same plan on all 500 stocks that traded in 2015. The 189 delisted ones count at the last price a holder got.
What will the average $100 become?
All 500, against today's 311
The same plan, the same ten years. The only change is which list you test. Switch between the two.
Buy and hold: today's list against every stock that existed (simulated)
Coloured: the list you picked. Grey: the other one. Dotted line: the $100 put in.
A percentage point is the gap between two percentages: from +86.3% to +184.7% is 184.7 − 86.3 = 98.4 percentage points. Today's list more than doubled the gain. This is survivorship bias: a test that only sees what survived to the end. (A bias is an error that leans one way, rather than one that comes from chance.)
Why it only goes one way
Here is where each of the 500 stocks ended. The bars count stocks by what their $100 became. The triangle marks the average. Take the delisted ones out and watch the average.
What $100 became in each of the 500 stocks (simulated)
Bar height: how many stocks ended in that range. Orange: delisted (dashed once taken out). The bottom scale is stretched like the chart of every stock earlier: from $100 to $1,000 takes as much room as from $10 to $100. Each bar covers values about a quarter higher than the one before.
All 189 delisted stocks ended below $25, far below the average of all 500, $186.34. Take numbers that sit below an average out of it, and the average rises (the low numbers that were pulling it down are gone). Today's list didn't drop stocks at random: it dropped them for doing badly. So here it moves the result up. Later you'll see the rare cases where it doesn't.
It is a peek, like the one in the last lesson. Choosing the list at the end uses something nobody knew in 2015: which stocks would survive.
Not only stocks
Any list chosen by how things ended has the same bias, whether it lists stocks, funds or strategies. A fund pools many people's money and invests it; a strategy is a fixed set of trading rules. For each list, say how it was chosen.
Every stock that traded on the exchange on the first day of 2015, each kept until it stopped trading.
At the start. The list is fixed in 2015, before anyone knew which would last. The stocks that died stay in it, up to their last price.
Not quite. The list is fixed in 2015, before anyone knew which would last. The stocks that died stay in it.
A seller's page of the strategies they still run, each with its results since it began.
Not quite. Strategies that lost were likely stopped and taken off the page. You see the ones that are still worth showing.
By how it ended. Strategies that lost were likely stopped and taken off the page. You see the ones that are still worth showing.
Survivorship bias, measured
Survivorship bias is the gap between a result measured on the survivors only and the same result on everything that existed at the start. For a buy-and-hold test, the result is the average return of the stocks on the list:
- R̄S
- the average return of the survivors (the stocks still trading at the end)
- R̄all
- the average return of everything that existed at the start
- R̄D
- the average return of the dead ones (delisted), up to their last price
- d
- the share that died: the number delisted ÷ the number at the start
R̄ is an average of returns, with each stock counting the same because each got $100; a return here is the total gain over the ten years, in %. Why the two forms agree: the average of all is the survivors' and the dead ones' averages, each weighted by its share, R̄all = (1 − d) × R̄S + d × R̄D. Subtracting that from R̄S: R̄S − (1 − d) × R̄S − d × R̄D = d × (R̄S − R̄D), the second form. It says the bias grows with how many died and how far they fell behind the survivors.
Survivors +184.7%, all 500 +86.3%: bias = 184.7 − 86.3 = 98.4 points. The 189 delisted ones averaged −75.5% ($100 became $24.46). Second form: d = 189 ÷ 500 = 0.378, and 0.378 × (184.7 − (−75.5)) = 0.378 × 260.2 = 98.4. The same answer.
- the plan is buy-and-hold (it gains when the stocks rise);
- the dead ones died for doing badly, so R̄D is below R̄S. Then the bias is positive: the survivors flatter the result.
Some leave for good reasons, such as another company buying them at a higher price: then the bias is smaller. A rule that bets on prices falling would have made its best trades on the dead ones, so for it the bias flips and the survivors make it look worse.
Try it on new numbers. 100 funds started ten years ago; 20 were closed. The 80 still open returned +60% on average, the 20 closed ones −30%. How many percentage points does a table of today's funds flatter the average?
The fix: the list as it stood
Test on the list as it stood at the start, not as it stands today: every stock that was trading then, the dead ones included up to their last price. This is a point-in-time universe (the universe is the list of stocks a test may choose from). Its average is every stock's return, dead or alive, added up and divided by the number that existed:
- NS, ND
- how many survived, how many died
- R̄S, R̄D
- their average returns, the dead ones' up to their last price
- R̄all
- the honest average: what the plan made on the list as it stood at the start
(311 × 184.7 + 189 × (−75.5)) ÷ 500 = (57,441.7 − 14,269.5) ÷ 500 = 43,172.2 ÷ 500 = +86.3%, the result you saw with all 500 switched on.
- you have the list as it was on the start date, not rebuilt later;
- you have the dead ones' prices up to the last one a holder could get;
- for a test that picks stocks again later, you use the list as it stood on each of those dates.
The data has quietly lost the dead ones' last prices or rows (lesson B4, Data quality). Or the list was picked after seeing results, such as keeping the settings that tested best (lesson B7, The best of many).
Try it on new numbers. 40 stocks traded at the start. The 30 survivors returned +50% on average; the 10 delisted ones −80%. What is the honest average return of all 40, in %?
What this means for your backtest
Three habits keep the dead in the test. Turn them over one at a time.
- Ask when the list was made.
A list made at the end chose its members by how they ended. A free download of "all stocks" can be today's stocks only.
- Test on the list as it stood.
On each date, the test may choose only from what was trading that day, including stocks that later died, up to their last price.
- Treat any list of winners as a list of survivors.
Funds, strategies, traders: before you believe the average, ask how many started and what became of the rest.
A fund table
What do you make of the +9%?
A friend's backtest
By how many percentage points did today's list flatter your friend's result?
Hint: 100 stocks existed at the start, and 20 of them died. Use bias = d × (R̄S − R̄D), or work out the average of all 100 first.
Three strategies, all up
What can you say about the seller's strategies as a whole?
Lesson done
A test on today's list sees only what survived. Stocks dropped for doing badly are missing, so the average comes out too high: on 500 simulated stocks, today's list showed +184.7% where all that existed made +86.3%. Test on the list as it stood at the start, dead ones included, and ask the same question of any list of winners you're shown.
Key ideas
- Delisted
- taken off the exchange: the stock stops trading
- Survivorship bias
- the gap between a result on the survivors only and on everything that existed at the start
- Percentage point
- the gap between two percentages: +86.3% to +184.7% is 98.4 points
- Universe
- the list of stocks a test may choose from
- Point-in-time universe
- the list as it stood on each date, including stocks that later died
Formulas
bias = R̄S − R̄all = d × (R̄S − R̄D) · R̄all = (NS × R̄S + ND × R̄D) ÷ (NS + ND)