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 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

Does Post-Earnings Announcement Drift Survive Real Filing Dates? PEAD Event Study in Python

What's the question?

Post-earnings announcement drift (PEAD) is the finding that companies reporting unexpectedly strong results keep outperforming for weeks afterwards, while those that disappoint keep lagging. Ball and Brown documented it in 1968 and it has been re-tested ever since.

Testing it requires choosing a date, and this is where most backtests go wrong. They use the fiscal period end, because every dataset carries that field. A company whose quarter closes on 31 March does not tell anybody what it earned on 31 March; the numbers become public when the filing lands on EDGAR, typically a month later. A 60-day window starting at the period end therefore contains the announcement itself, which is the largest single move of the whole episode. Returns booked inside that window were unavailable to anybody trading the results, because the results were not public yet.

So: how much of measured drift is drift, and how much is announcement reaction smuggled in by a careless clock?

The approach

No analyst estimates enter this test. The expectation has to come from a company’s own record, which gives standardised unexpected earnings (SUE) built on a seasonal random walk: the expected figure for a quarter is the same quarter one year earlier. That is a time-series proxy for surprise, not an estimate-based one.

  1. 40 large caps across technology, healthcare, energy, financials, staples and industrials, using quarterly net income from 2013 onward.
  2. Net income rather than per-share earnings, since a share count resetting at a stock split makes per-share figures non-comparable year over year.
  3. Unexpected earnings is net income minus the same quarter a year prior, standardised by the dispersion of that company’s own past year-over-year changes, lagged one quarter so no event contaminates its own scale. At least 8 prior changes required.
  4. Keep quarters whose filing date falls 1 to 120 days after the period end, the statutory reporting window. filing_date records the filing a figure came from, which for a restated quarter can be a later comparative filing.
  5. Sort events into SUE quintiles, then measure cumulative abnormal return as the daily return minus SPY summed across 60 trading days from the day after the event.
  6. Run it twice: clock at filing_date, then at period_end.

WMT retains too few quarters inside that window to standardise and drops, leaving 39 names and 934 events from January 2018 to April 2026, dominated by interim quarters.

Code

import numpy as np
import pandas as pd
from scipy.stats import ttest_ind
import xfinlink as xfl

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

TICKERS = ["AAPL", "MSFT", "GOOGL", "AMZN", "META", "NVDA", "JPM", "JNJ", "V",
           "PG", "XOM", "HD", "CVX", "MRK", "ABBV", "PEP", "KO", "WMT", "COST",
           "MCD", "CSCO", "ADBE", "CRM", "TXN", "QCOM", "AMD", "INTC", "NKE",
           "UNH", "LIN", "HON", "CAT", "LMT", "BA", "GE", "UPS", "MMM", "T",
           "VZ", "DIS"]
HORIZON, MIN_HISTORY, MAX_LAG = 60, 8, 120

fun = xfl.fundamentals(TICKERS, period_type="quarterly", start="2013-01-01",
                       fields=["net_income", "filing_date", "period_end"])
fun = fun.drop_duplicates(subset=["ticker", "fiscal_year", "fiscal_period"])
fun = fun.dropna(subset=["net_income", "filing_date", "period_end"])
fun["lag"] = (fun["filing_date"] - fun["period_end"]).dt.days
fun = fun[(fun["lag"] > 0) & (fun["lag"] <= MAX_LAG)]

# seasonal random walk: expectation is the same fiscal quarter one year ago
prev = fun[["ticker", "fiscal_year", "fiscal_period", "net_income"]].copy()
prev["fiscal_year"] += 1
prev = prev.rename(columns={"net_income": "net_income_yoy"})
ev = fun.merge(prev, on=["ticker", "fiscal_year", "fiscal_period"], how="inner")
ev["ue"] = ev["net_income"] - ev["net_income_yoy"]
ev = ev.sort_values(["ticker", "period_end"])

# shift(1) keeps the current event out of its own scaling factor
ev["scale"] = ev.groupby("ticker")["ue"].transform(
    lambda s: s.shift(1).expanding(MIN_HISTORY).std())
ev = ev.dropna(subset=["scale"])
ev = ev[ev["scale"] > 0]
ev["sue"] = ev["ue"] / ev["scale"]

universe = sorted(ev["ticker"].unique())
series = {t: xfl.prices(t, start="2017-06-01", fields=["return_daily"])
          .set_index("date")["return_daily"] for t in universe + ["SPY"]}

# SPY defines the trading calendar; abnormal return is the excess over it
cal = np.array(sorted(series["SPY"].index.unique()))
spy = series["SPY"].reindex(cal)
excess = {t: (series[t].reindex(cal) - spy).to_numpy() for t in universe}

def car(ticker, event_date):
    i = int(np.searchsorted(cal, np.datetime64(event_date), side="right"))
    if i + HORIZON > len(cal):
        return None
    return np.cumsum(excess[ticker][i:i + HORIZON])

rows = []
for r in ev[ev["filing_date"] >= "2018-01-01"].itertuples():
    a, b = car(r.ticker, r.filing_date), car(r.ticker, r.period_end)
    if a is None or b is None:
        continue
    rows.append({"sue": r.sue, "car_filing": a[-1], "car_period": b[-1]})

res = pd.DataFrame(rows)
res["bucket"] = pd.qcut(res["sue"], 5, labels=["Q1 low", "Q2", "Q3", "Q4",
                                               "Q5 high"])
print(res.groupby("bucket", observed=True)[["car_filing", "car_period"]]
      .mean().mul(100).round(2).to_string())

for col in ("car_filing", "car_period"):
    top = res.loc[res["bucket"] == "Q5 high", col]
    bot = res.loc[res["bucket"] == "Q1 low", col]
    t, p = ttest_ind(top, bot, equal_var=False)
    print(f"{col}: spread {(top.mean() - bot.mean()) * 100:.2f}%  "
          f"t={t:.2f}  p={p:.3f}")

Full script with formatting and visualisation: post-earnings-announcement-drift-filing-date-python.py

Output

Cumulative abnormal return by earnings surprise quintile over 60 trading days, measured from the filing date and from the fiscal period end.
Post-earnings announcement drift | seasonal random walk SUE | 60 trading days
universe 39 large caps | events 934 | 2018-01-05 to 2026-04-27
filing lag after period end: median 30d  p5 22d  p95 38d
quarters kept by the 1-120d statutory window screen: 1723 of 2120

SUE bucket  events  mean SUE  CAR from filing  CAR from period end  pre-filing leg
Q1 low         187     -2.22           -0.02%               -1.32%          -1.74%
Q2             187     -0.20            0.53%               -1.83%          -1.46%
Q3             186      0.28           -0.69%               -0.55%          -0.37%
Q4             187      0.91            1.00%                1.86%           1.25%
Q5 high        187      3.05            1.43%                1.65%           1.23%

top-minus-bottom spread from filing date:    1.45%
top-minus-bottom spread from period end:     2.97%
inflation from timing off period end:        1.53%  (2.05x)
top-minus-bottom spread, pre-filing leg:     2.97%  (the announcement reaction the period-end clock swallows)

Welch test on the top-minus-bottom spread
  from filing date:  t =  1.11   p = 0.266
  from period end:   t =  2.23   p = 0.026

events by fiscal quarter: Q1 310  Q2 308  Q3 303  Q4 13
CAR range across all events: -55.8% to 53.4%
NaN check | sue 0  car_filing 0  car_period 0

What this tells us

In the right panel the quintiles separate cleanly, and the separation begins around day 21, which is the median trading-day offset between period end and filing date. The ordering does not emerge because the market slowly digested stale news. It emerges the moment the news enters the measurement window.

The top-minus-bottom spread is 2.97% from the period end against 1.45% from the filing date, so the naive clock roughly doubles the answer. Significance moves further than magnitude does: from the period end the spread carries t = 2.23 and p = 0.026, clearing the conventional threshold, while from the filing date it drops to t = 1.11 and p = 0.266. Shifting the start date by three weeks converts a publishable result into noise.

The pre-filing column isolates the mechanism, measuring excess return between period end and filing date only. That is the stretch the naive clock banks before an honest clock starts, and its top-minus-bottom spread of 2.97% matches the full period-end spread almost exactly. Everything the naive version appears to earn arrives before the filing.

What remains is small and imperfectly ordered: Q5 high delivers +1.43% against -0.02% for Q1 low, while Q2 at +0.53% sits above Q3 at -0.69%. Weak and non-monotonic is the expected result here. PEAD was always strongest among small, thinly followed stocks, and decades of publication have competed most of it out of mega caps like these.

So what?

Key any fundamental event study off the filing date. A backtest built on period ends cannot separate drift from reaction even in principle, which makes its headline number untestable rather than merely optimistic.

Treat the 2.05x gap as calibration for what other silent look-ahead is worth. A three-week timing error, introduced by nothing more sinister than using the field that happened to be present, doubled a spread and flipped its p-value.

The honest number does not support trading PEAD in this universe. A 1.45% spread over three months, before costs, with p = 0.266, is not an edge. Two directions remain worth testing: smaller and less covered names where the anomaly was originally strongest, and horizons much shorter than 60 days, where any genuine drift should concentrate.

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