BLOG

Behind the numbers.

Code examples, market analysis, and data quality deep-dives.

Does Post-Earnings Announcement Drift Survive Real Filing Dates? PEAD Event Study in Python
Do Insider Buying Clusters Predict Returns? Signal Testing in Python
Does the S&P 500 Index Effect Still Exist? Event Study in Python
Are Companies Leaving the S&P 500 Faster Than They Used To? Index Survival Analysis in Python
Does Gross Profitability Predict Stock Returns? Quintile Factor Test in Python
What Growth Rate Is the Market Pricing In? Reverse DCF in Python
Does a Strong Balance Sheet Cushion Drawdowns? Leverage and Downside Risk in Python
Does Ticker Recycling Corrupt a Mean-Reversion Backtest? Entity-Resolved Z-Scores in Python
How Much of a Growth Screen's Backtested Edge Is Survivorship Bias? Point-in-Time Index Testing in Python
Why Do Leveraged ETFs Decay? Measuring Volatility Drag in Python
Are Consumer Staples Margins Shrinking Under Inflation? Gross Margin Trend Analysis in Python
Do Weak Jobs Reports Predict Market Drawdowns? NFP Surprise Event Study in Python
Is the Rotation From Tech to Industrials Backed by Earnings? Relative EPS Growth Analysis in Python
Is the Semiconductor Rally Broadening Beyond NVIDIA? Return Dispersion Analysis in Python
Which Stocks Benefit Most When Oil Prices Fall? Oil Beta Screening in Python
Do Bond Returns Predict Stock Returns? Granger Causality Test in Python
Which Stocks Actually Drive Portfolio Returns? Shapley Value Attribution in Python
Does "Sell in May" Still Work? Calendar Anomaly Backtest in Python
How to Build Complete Price History Through Ticker Changes? Entity Resolution in Python
Are KO and PEP Cointegrated? Pairs Trading Signal Construction in Python
Which Commodities Have the Strongest Momentum? Rotation Backtest in Python
Which Commodity ETFs Have the Worst Tail Risk? Expected Shortfall in Python
Are Gold Miners Leveraged Gold Bets? Rolling Beta Analysis in Python
Does the Base-Metals-to-Gold Ratio Lead Cyclical Stocks? Signal Test in Python
Can Risk Parity Tame Commodity Volatility? Portfolio Optimization in Python
Are Power Stocks Becoming an AI Infrastructure Trade? Momentum Screening in Python
Which AI Chip Stocks Have Margin Momentum? Profitability Trend Analysis in Python
Which AI Stocks Are Cheapest Relative to Growth? Growth-Adjusted Valuation in Python
Does AI Stock Leadership Persist? Momentum Backtest in Python
Which AI Stocks Have the Cleanest Balance Sheets? Net Cash Screening in Python
Can Risk Parity Reduce Mega-Cap Drawdowns? Portfolio Optimization in Python
Which Growth Stocks Are Self-Funding? Cash-Flow Quality Screening in Python
Which Sectors Struggle When the Dollar Rallies? Sector Rotation Analysis in Python
Do Cheap Stocks Hold Up When Bonds Sell Off? Valuation Rotation in Python
Does the Nasdaq 100 Have Better Growth Quality Than the Dow? Index Constituent Analysis in Python
Do Healthcare Cash-Flow Margins Predict Returns? Signal Evaluation in Python
Which Dividend Stocks Survive a Cash-Flow Stress Test? Dividend Screening in Python
Does Heavy Insider Selling Predict Weak Returns? Insider Flow Test in Python
Can Quality Screens Reduce Small-Cap Balance-Sheet Risk? Russell 2000 Test in Python
Which Retailers Have Positive Operating Leverage? Margin Screening in Python
Is MSTR a Leveraged Bitcoin Proxy? Rolling Beta Analysis in Python
Is Micron's Memory Cycle Recovering? Inventory and Margin Forecasting in Python
Which Sectors Work When Bonds Rally? Rate-Sensitive Rotation in Python
Do One-Month Price Extremes Reverse? Signal Evaluation in Python
Do Low-Volatility S&P 500 Stocks Reduce Drawdowns? Factor Test in Python
Is AI Capex Paying Back Fast Enough? Revenue Hurdle Forecasting in Python
Could Shorter AI Asset Lives Hit Earnings? Depreciation Stress Test in Python
How Much AI Capex Risk Can a Portfolio Remove? Constrained Optimization in Python
Is the AI Capex Trade Crowded? Rolling Volatility and Sector Rotation in Python
Did the AI Boom Come From Existing S&P 500 Members? Point-in-Time Momentum Test in Python
Is AI Revenue Circular? Customer-Vendor Capex Loop Analysis in Python
Is the AI Trade Connected to Private Credit? Rolling Correlation Network in Python
Is Apollo More Balance-Sheet Sensitive Than Peers? Leverage Screen in Python
Are AI Earnings Supported by Cash Flow? Accrual and Capex Screen in Python
Can Defensive Stocks Hedge AI Drawdowns? Basket Regime Test in Python
How Fast Does the Market Price In Fed Decisions? FOMC Event Study in Python
How Much Are Options Sellers Overpaid? The Variance Risk Premium in Python
Which Companies Have the Worst Earnings Quality? Sloan Accrual Screen with Geographic Revenue Data in Python
Does the Oil-to-Gold Ratio Signal Recessions? XLE/GLD Backtest in Python
Is AI Spending Crowding Out Free Cash Flow? Capex Sustainability Across the Mag 7 in Python
Does a Long Energy / Short Bonds Portfolio Capture Inflation Surprises? Factor Construction in Python
Can a Hidden Markov Model Detect Oil Market Regimes? HMM Analysis in Python
Do Grain Prices Predict Food Inflation? Granger Causality Test in Python
Does the Corporate Credit Spread Predict Stock Market Crashes? BAA-AAA Spread Analysis in Python
Do Oil Stocks Hedge Inflation? Rolling Beta Analysis in Python
Which Stocks Are Most Rate-Sensitive? Equity Duration via Bond Beta in Python
Which Companies Have the Highest Accrual Ratios? Earnings Quality Screening in Python
Is Alpha Persistent or Decaying? Rolling Sharpe Ratio Analysis in Python
Are Markets Trending or Mean-Reverting? Hurst Exponent Analysis in Python
Is Consumer Discretionary vs Staples a Leading Indicator? XLY/XLP Ratio Analysis in Python
Does Heavy Capex Predict Future Stock Returns? Capital Expenditure Analysis in Python
How to Estimate Cost of Equity Using CAPM in Python
Is Volatility Predictable? Testing for Volatility Clustering in Python
Which Industrials Are Overleveraged? Net Debt to EBITDA Screening in Python
GM Before and After Bankruptcy: Why Entity Resolution Matters for Financial Data
What Is Adjusted Beta? Merrill Lynch Beta Shrinkage in Python
How Good Is a Stock Pick? Information Ratio and Tracking Error in Python
Do Stock Returns Follow a Normal Distribution? Testing for Fat Tails in Python
Which Large Caps Have the Highest Free Cash Flow Yield? FCF Screening in Python
Which Sectors Won Over 5 Years? Sector Rotation Analysis in Python
How to Forecast Stock Volatility with GARCH Models in Python
Are Stock Prices Mean-Reverting? Augmented Dickey-Fuller Test in Python
How to Calculate CAPM Alpha and Beta with Regression in Python
How to Compare Sector Sharpe Ratios and Sortino Ratios in Python
DELL: Why Stitching Historical Price Data Together Is Wrong
How to Analyze Drawdown and Recovery for Bank Stocks in Python
How to Screen SaaS Stocks by Revenue Growth and Cash Flow in Python
How to Screen REITs by Dividend Yield and Valuation in Python
How Correlated Are the Magnificent 7? Intra-Group Correlation in Python
AAPL vs XOM: Do Individual Stocks Have Seasonal Patterns?
How to Rank Large-Cap Stocks by Momentum in Python
How to Build a Multi-Endpoint Financial Dashboard in Python
How to Compare Volatility Across Energy Stocks in Python
How to Screen Healthcare Stocks by Valuation in Python
How to Build a Sector Correlation Matrix for Portfolio Diversification in Python
How to Find Oversold and Overbought Stocks Using Z-Scores in Python
How to Measure Earnings Quality: Cash Flow vs Net Income in Python
How to Build a Multi-Factor Stock Screen in Python (Value + Momentum + Quality)
How to Build a Simple DCF Model for Any Stock in Python
How to Screen Tech Stocks by Revenue Growth in Python
How to Screen Stocks by Balance Sheet Health in Python
Is "Sell in May" Real? SPY Monthly Seasonality Over 10 Years
How to Compare Sector Performance YTD Using Python
How to Track S&P 500 Additions and Removals Over Time in Python
How to Screen Dividend Stocks by Yield and Quality in Python
How to Calculate Max Drawdown and Recovery Time for Any Stock in Python
How to Compare Profitability Across Mega-Cap Tech Stocks in Python
Why Ticker Symbols Are Unreliable: The Recycling Problem Every Quant Should Know
How to Calculate and Compare Stock Volatility in Python
How to Screen Blue-Chip Stocks by P/E Ratio in Python
How to Track Companies Through Ticker Changes, Bankruptcies, and Renames in Python
S&P 500 Turnover: How Much the Index Has Changed Since 2010
How to Calculate Stock Beta and Correlation in Python
← All articles

Are Companies Leaving the S&P 500 Faster Than They Used To? Index Survival Analysis in Python

What's the question?

Corporate longevity briefings from Innosight put average S&P 500 tenure at 33 years in 1964 and 24 years in 2016, projecting 12 by 2027. The figure has become shorthand for accelerating creative destruction.

Average tenure is harder to measure than it looks. The obvious calculation takes every company that has left the index, measures how long each stayed, and averages. A company still in the index contributes nothing, because its tenure has not finished. Statisticians call this right-censoring, and the error does not cancel out: the memberships still running are the long ones, so dropping them pulls the average down, and it pulls hardest on recent cohorts.

So a measured decline could be real, or it could be an artifact. That is falsifiable: does a statistic immune to censoring show the same decline? The censoring-free version is a fixed-horizon survival rate. Take every company that joined the index in a given year and ask what fraction was still in it ten years later. Every member of the cohort has a definite answer, so nobody is dropped.

The approach

The S&P 500 membership event log runs from 3 July 1957 to 7 May 2026 and holds 2,605 dated additions and removals. Point-in-time rosters come from the same source through as_of.

  1. Page through the whole event log with index_events, 1,000 rows per request.
  2. Turn the log into membership spells by counting open listings per company, since it records securities and a firm with two share classes generates two additions. 1,447 spells result.
  3. Group spells into five-year cohorts by joining year, restricted to 1980 through 2014 so every cohort has had a full ten years to be observed. Compute the naive number, mean tenure of ended spells, and the ten-year survival rate.
  4. Rebuild the estimate from rosters alone: overlap index("sp500", as_of=Y) with the roster ten years later, matching on the spell rather than the company.
  5. Rebuild it a third time from raw event counts: removals in a period divided by index seats gives an annual exit rate, compounding to an implied ten-year survival. Nothing is paired.
  6. Test 1980s cohorts against 2005 to 2014 cohorts with a two-proportion z-test.

Only dates and counts enter these calculations, and the three estimators share no logic, so agreement between them counts as evidence rather than repetition. Two limits belong on the record. Founding-roster additions are suppressed by design, since they record who was already a member when the log opens, so 42 current constituents get no cohort. Roster sizes are taken as observed at each date, 433 names in 1990 against 492 in 2026, so cohorts before 1980 are excluded and every rate is computed on the observed count rather than a nominal 500.

Code

import numpy as np
import pandas as pd
import xfinlink as xfl
from statsmodels.stats.proportion import proportions_ztest

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

HORIZON = pd.Timedelta(days=3652)  # 10 years

frames, offset = [], 0
while True:
    page = xfl.index_events("sp500", start="1957-01-01", limit=1000, offset=offset)
    if page.empty:
        break
    frames.append(page)
    offset += len(page)
    if len(page) < 1000:
        break

events = pd.concat(frames, ignore_index=True)
events["effective_date"] = pd.to_datetime(events["effective_date"])
events = events.sort_values(["entity_id", "effective_date"])

# a spell runs from the addition that opens membership to the removal that ends it
spells = []
for entity_id, g in events.groupby("entity_id"):
    open_listings, spell_start = 0, None
    for _, row in g.iterrows():
        if row["event_type"] == "added":
            if open_listings == 0:
                spell_start = row["effective_date"]
            open_listings += 1
        elif open_listings > 0:
            open_listings -= 1
            if open_listings == 0:
                spells.append((entity_id, spell_start, row["effective_date"]))
    if open_listings > 0:  # still a member: right-censored
        spells.append((entity_id, spell_start, pd.NaT))

sp = pd.DataFrame(spells, columns=["entity_id", "added", "removed"])
sp["cohort"] = sp["added"].dt.year
sp["bucket"] = (sp["cohort"] // 5) * 5
sp["tenure"] = (sp["removed"] - sp["added"]).dt.days / 365.25

w = sp[sp["cohort"].between(1980, 2014)].copy()
w["survived_10y"] = np.where(
    w["removed"].isna(), 1, (w["removed"] > w["added"] + HORIZON).astype(int)
)

cohorts = w.groupby("bucket").agg(
    additions=("added", "size"),
    naive_tenure=("tenure", "mean"),        # biased: ended spells only
    survival_10y=("survived_10y", "mean"),  # censoring-free
)

# second estimator: roster overlap 10 years apart, keyed on the membership
# spell (entity_id + added_date) so two spells of one company cannot match
def spell_keys(as_of):
    snap = xfl.index("sp500", as_of=as_of)
    return set(zip(snap["entity_id"], snap["added_date"])), len(snap)

retention = []
for year in range(1980, 2015):
    now, size = spell_keys(f"{year}-01-01")
    later, _ = spell_keys(f"{year + 10}-01-01")
    retention.append((year, size, len(now & later) / len(now)))

ret = pd.DataFrame(retention, columns=["year", "roster", "retained_10y"])
ret["bucket"] = (ret["year"] // 5) * 5
cohorts = cohorts.join(ret.groupby("bucket")["retained_10y"].mean())

# third estimator: exit rate from event counts alone, nothing paired
events["year"] = events["effective_date"].dt.year
removals = events[events["event_type"] == "removed"].groupby("year").size()
seats = ret.set_index("year")["roster"]
for b in cohorts.index:
    yrs = range(b, b + 5)
    rate = sum(int(removals.get(y, 0)) for y in yrs) / sum(int(seats[y]) for y in yrs)
    cohorts.loc[b, "implied_10y"] = (1 - rate) ** 10

early, late = w[w["cohort"] < 1990], w[w["cohort"] >= 2005]
zstat, pval = proportions_ztest(
    [early["survived_10y"].sum(), late["survived_10y"].sum()], [len(early), len(late)]
)
print(cohorts.round(3))
print(f"z={zstat:.2f}, p={pval:.3f}")

Full script with formatting and visualisation: sp500-membership-tenure-survival-python.py

Output

Average tenure of ended S&P 500 memberships falls by 55% across 1980 to 2014 joining cohorts, while the ten-year survival rate of the same cohorts stays near 60%
=== S&P 500 membership durability by addition cohort ===
Event log: 2605 events, 1957-07-03 to 2026-05-07. Spells reconstructed: 1447

Cohort       Added  Ended  NaiveTenure  StillIn  Surv10y  Retain10y
1980-84        112     87        13.8y     22%    66.1%      65.5%
1985-89        134    111        12.0y     17%    64.2%      67.4%
1990-94         58     49        11.4y     16%    53.4%      57.2%
1995-99        159    107         8.8y     33%    57.2%      55.9%
2000-04        137    101         8.9y     26%    54.0%      61.0%
2005-09        149     91         8.1y     39%    58.4%      62.8%
2010-14         87     42         6.2y     52%    58.6%      65.5%

Naive mean tenure of ended spells: 13.8y (1980-84) -> 6.2y (2010-14), -55%
10-year survival:                  66.1% (1980-84) -> 58.6% (2010-14)
Roster retention (independent):    65.5% (1980-84) -> 65.5% (2010-14)
Exit-rate implied survival:        67.3% (1980-84) -> 70.5% (2010-14)
Trend in 10-year survival: -2.4 pp per decade
1980s cohorts 65.0% (n=246) vs 2005-14 cohorts 58.5% (n=236): z=1.48, p=0.138
Censoring: 22% of the 1980-84 cohort is still a member and excluded from its
tenure average; 52% of the 2010-14 cohort.

Period       Exits   Roster  AnnualExit  Implied10y
1980-84         74      381       3.89%       67.3%
1985-89        103      417       4.94%       60.3%
1990-94         50      435       2.30%       79.2%
1995-99        150      442       6.78%       49.5%
2000-04        117      467       5.01%       59.8%
2005-09        140      478       5.85%       54.7%
2010-14         84      489       3.44%       70.5%

--- validation: spells vs point-in-time rosters ---
1990-01-01: roster 433, spells open 338, open but not in roster 0, in roster via founding entry 95
2005-01-01: roster 474, spells open 416, open but not in roster 0, in roster via founding entry 58
2026-01-01: roster 492, spells open 450, open but not in roster 0, in roster via founding entry 42

What this tells us

The naive number reproduces the familiar story. Mean tenure of completed memberships falls from 13.8 years for the 1980-84 intake to 6.2 years for the 2010-14 intake, a drop of 55% broken only by the 2000-04 bucket.

The censoring-free measure of the same 836 companies says otherwise. Ten-year survival was 66.1% for the earliest cohort and 58.6% for the latest, a fitted decline of 2.4 percentage points per decade, and the 1980s intake against the 2005 to 2014 intake gives z = 1.48, p = 0.138. Spell-matched roster retention lands on 65.5% at both ends, and the exit-rate estimator implies 67.3% against 70.5%. The collapse is in the statistic, not in the companies.

The StillIn column shows where it comes from. Only 22% of the 1980-84 cohort remains in the index today, so the naive average captures most of that group. For 2010-14 the figure is 52%, and every one of those survivors is past eleven years of membership, excluded by construction. The naive statistic measures how much of a cohort has finished, not how durable it is.

Exit rates themselves move far more than survival does, from 2.30% of seats per year in the early 1990s to 6.78% in the late 1990s. A cohort straddles several such periods, which is why the 1990-94 intake looks weakest despite joining in the calmest stretch on record.

So what?

Anyone quoting a corporate-longevity number should check whether the denominator includes companies still in the index; if it does not, the number falls over time whether or not durability changes. Any duration statistic computed only on completed cases inherits that flaw, average holding period and average time-to-default included.

For index research the base rate has held near 60% for forty years: a company joining the S&P 500 has roughly a 4-in-10 chance of leaving within a decade. Turnover budgets for index-tracking mandates, and any model treating membership as a decaying asset, belong on that flat rate rather than an extrapolated decline. Timing is what varies, by a factor of three between calm and turbulent stretches.

Rebuilding any of it takes one event-log pull and a loop over as_of snapshots.

Built with xfinlink — free financial data API for Python. pip install xfinlink

Built with xfinlink — free financial data API for Python. pip install xfinlink
← All articles