← All posts

Dollar-Cost Averaging vs Lump Sum: Survivorship Bias Test

Dollar-cost averaging and survivorship bias: a lump sum beats 12 instalments by 5.30 points on past S&P 500 rosters and by 8.30 on today’s list, 2002-2023.

Dollar-cost averaging looks a worse deal on today’s S&P 500 list than it was. A lump sum in one index member beat 12 monthly instalments by an average 5.30 points over 12 months on the rosters in force at each start from 2002 to 2023, and by 8.30 points on today’s list traced back, so survivorship bias supplies 2.99 points of that apparent cost. It also hides the protection: on the real rosters a lump sum lost more than half 2.60% of the time, against 1.48% on today’s list.

Does today’s list make waiting look too expensive?

Dollar-cost averaging spreads a purchase over equal instalments at fixed dates. A lump sum invests the same money at once. Because stocks have returned more than cash on average, the lump sum usually wins; instalments leave money waiting, and in exchange they soften a fall that comes early.

Both sides of that trade depend on which stocks enter the test. A list drawn today holds companies that stayed large or grew into the index and leaves out members that collapsed, which is survivorship bias in a backtest. Rising stocks punish waiting, and collapsing stocks reward it. A survivor list should therefore overstate the cost of instalments and understate the protection.

Running 253 monthly starts on two rosters

  1. Rosters: the S&P 500 members on the last business day of each month from December 2002 to December 2023, from xfl.index("sp500", as_of=...) (the index membership reference covers the call), and today’s roster traced back, using the stocks that had a price on each start.
  2. Plans: for every stock and start, $1 invested at once, or 1/12 at that month-end and at each of the next 11. Both are valued 12 months after the start.
  3. Waiting money earns the total return of SHY, a fund of 1-3 year Treasuries.
  4. Returns are monthly and include dividends. A stock that leaves the exchange takes its recorded delisting return (an exit with none keeps its last price), then the money moves to SHY for good, later instalments included. Leaving the index does not end a plan.
  5. Each start month counts equally. Newey-West t-statistics, which allow for overlapping periods, use 12 lags. Costs and taxes are left out.

That produces 126,987 plans on the rosters in force and 109,563 on today’s list. The history of S&P 500 additions and deletions dates each change between rosters.

Code

import numpy as np
import pandas as pd
import xfinlink as xfl

xfl.set_api_key("YOUR_API_KEY")  # free at https://xfinlink.com/signup

starts = pd.period_range("2002-12", "2023-12", freq="M")
N = 12
ros = {m: xfl.index("sp500", as_of=pd.date_range(m.start_time, m.end_time, freq="B")[-1].strftime("%Y-%m-%d"))
       for m in starts}
today = xfl.index("sp500").dropna(subset=["entity_id"])
now = {int(e) for e in today.entity_id}
ids = sorted({int(e) for r in ros.values() for e in r.entity_id.dropna()} | now)
KW = dict(start="2002-11-01", end="2024-12-31", interval="1mo", fields=["close", "adj_close", "return_daily"])
px = pd.concat([xfl.prices(entity_id=ids[i:i + 100], max_rows=250_000, **KW) for i in range(0, len(ids), 100)],
               ignore_index=True)
px["month"] = pd.to_datetime(px.date).dt.to_period("M")
months = pd.period_range("2002-12", "2024-12", freq="M")
R = px.pivot_table(index="month", columns="entity_id", values="return_daily", aggfunc="first").reindex(months)
C = px.pivot_table(index="month", columns="entity_id", values="close", aggfunc="first").reindex(months)
shy = xfl.prices("SHY", **KW)
cash = shy.assign(month=pd.to_datetime(shy.date).dt.to_period("M")).set_index("month").return_daily.reindex(months)

# Exits: add the recorded delisting return (one exit year per call)
last = R.apply(pd.Series.last_valid_index).dropna()
ended = last[last < months[-1]]
for y, g in ended.groupby(ended.map(lambda p: p.year)):
    d = xfl.prices(entity_id=[int(e) for e in g.index], start=f"{y}-01-01", end="2024-12-31", interval="1mo",
                   fields=["return_daily"])
    for e, v in (d.attrs["meta"].get("delisting") or {}).items():
        e, dr = int(e), v.get("delisting_return")
        if e in ended.index and dr is not None and not np.isnan(dr):
            m = last[e] if pd.Period(v["event_date"], "M") <= last[e] else last[e] + 1
            R.loc[m, e] = (1 + np.nan_to_num(R.loc[m, e])) * (1 + dr) - 1

def plans(m, es):  # 12-month growth of $1: all at month-end m, or 1/12 at each of 12 month-ends from m
    i = months.get_loc(m)
    es = [e for e in es if e in C and pd.notna(C[e].iloc[i])]
    g = 1 + R[es].iloc[i + 1:i + 1 + N].to_numpy()
    c = 1 + cash.iloc[i + 1:i + 1 + N].to_numpy()
    off = np.cumsum(np.isnan(g), axis=0) > 0  # first month without a bar, and all after it
    g = np.where(off, c[:, None], g)          # off the exchange: the money sits in SHY
    stock, wait = np.zeros(len(es)), np.ones(len(es))
    for k in range(N):
        buy = wait / (N - k)
        stock, wait = (stock + buy) * g[k], (wait - buy) * c[k]
    return pd.DataFrame({"m": m, "e": es, "lump": g.prod(axis=0), "dca": stock + wait})

honest = pd.concat([plans(m, [int(e) for e in ros[m].entity_id.dropna()]) for m in starts])
naive = pd.concat([plans(m, sorted(now)) for m in starts])
for label, d in (("roster in force", honest), ("today's roster", naive)):
    d = d.assign(gap=d.lump - d.dca, win=d.lump > d.dca, halved=d.lump < .5, halved_dca=d.dca < .5)
    print(label, d.groupby("m")[["lump", "dca", "gap", "win", "halved", "halved_dca"]].mean().mean().round(4).to_dict())

Full script with formatting and visualisation: dollar-cost-averaging-survivorship-bias-python.py

Output

Line chart of the average lump-sum advantage over 12 monthly instalments by start month, December 2002 to December 2023: today’s S&P 500 roster traced back sits above the roster in force in 244 of 253 months
253 start months, 2002-12 to 2023-12; 126,987 roster lines, 126,987 plans in force, 109,563 on today's list; 996 securities; 333 delisting returns applied
                                        in force     today
Lump sum, mean 12-month return            12.89%    18.86%
12 instalments, mean return                7.59%    10.57%
Lump sum minus instalments                 5.30%     8.30%
Lump sum ends ahead                       62.14%    66.71%
Lump sum lost more than half               2.60%     1.48%
Instalments lost more than half            0.70%     0.36%
Left the exchange within 12 months         2.33%     0.01%
Today's list adds 2.99 points to the gap (Newey-West t 8.67); wider in 244 of 253 start months
  gap by start month, in force: mean 5.30, t 3.08
  gap by start month, today: mean 8.30, t 4.65
  lump-sum win rate: today's list higher in 241 of 253 start months

group                                         plans     lump  instal.     gap     win  halved
Members then and on today's list             80,309   14.95%    8.71%    6.24   65.5%   1.41%
Members then, not on today's list            46,678    7.65%    4.78%    2.86   54.4%   5.06%
Not members then, on today's list            29,254   31.20%   16.52%   14.68   70.5%   1.91%

By calendar year of start month: gap in points (lump-sum win rate)
2002  in force  13.58 (76%)   today  23.96 (80%)
2003  in force  16.76 (84%)   today  24.82 (88%)
2004  in force   5.94 (66%)   today   9.27 (73%)
2005  in force   5.95 (66%)   today  10.64 (73%)
2006  in force   5.10 (66%)   today   7.63 (70%)
2007  in force  -6.93 (26%)   today  -3.84 (31%)
2008  in force -20.26 (18%)   today -17.37 (18%)
2009  in force  21.64 (81%)   today  22.59 (84%)
2010  in force   9.68 (75%)   today  11.86 (79%)
2011  in force   1.70 (54%)   today   4.36 (60%)
2012  in force  11.25 (79%)   today  12.93 (82%)
2013  in force  11.07 (83%)   today  13.26 (85%)
2014  in force   4.87 (67%)   today   7.24 (74%)
2015  in force  -0.78 (49%)   today   1.51 (55%)
2016  in force   8.98 (74%)   today  12.40 (82%)
2017  in force   6.51 (69%)   today   9.94 (76%)
2018  in force   0.92 (52%)   today   3.66 (58%)
2019  in force  -3.14 (44%)   today   0.87 (49%)
2020  in force  20.39 (82%)   today  22.44 (83%)
2021  in force   4.33 (59%)   today   4.96 (61%)
2022  in force   0.74 (49%)   today   2.78 (52%)
2023  in force   5.92 (61%)   today  10.95 (67%)
5th percentile of outcomes, in force: lump -28.3%, instalments -17.3%; today -21.0%, -13.2%

Both sides of the trade-off move

The lump sum wins on either list, and most of its lead is real. On the rosters in force it finished ahead in 62.14% of plans, with a gap of 5.30 points (t 3.08). Part of that is exposure: an instalment plan’s schedule puts on average 54% of the money in the stock. Today’s list raises the win rate to 66.71% and the gap to 8.30. The extra 2.99 points have a t-statistic of 8.67.

Members since dropped from the list explain 0.94 points of the difference. Their lump sums led by 2.86 points, against 6.24 for members still listed. The other 2.06 come from stocks that were not members at the start, 26.7% of today’s-list plans, whose lump sums returned 31.20%. Growing into the index means rising, which is when waiting costs most.

Protection moves the opposite way. Instalments cut the chance of losing more than half from 2.60% to 0.70% on the rosters in force, a reduction of 1.90 points. Today’s list reports 1.12. Members no longer listed are 36.8% of the plans in force and 69% of the lump sums that lost more than half. Lehman Brothers, started at the end of August 2008, left $0.003 of a one-dollar lump sum and $0.952 of the instalment plan, since only the first instalment bought shares before the failure.

In some years the choice of roster picks the winner. For plans started in 2015 and 2019, instalments beat the lump sum by 0.78 and 3.14 points on the rosters in force; today’s list has the lump sum ahead by 1.51 and 0.87.

Pricing instalments before choosing them

Spreading a purchase of one large US stock across a year cost about 5 points of 12-month return, and a survivor list inflates that price by more than half. What it bought was a chance of losing more than half of 0.70% instead of 2.60%.

Test an entry rule on the S&P 500 members on each start date, and follow every stock to its exit. Report the frequency of large losses beside the average gap; survivors distort the two in opposite directions. What happens after a holding has already halved is the subject of a recovery test on dated and current rosters.

Built with xfinlink — free financial data API for Python.