Momentum Crash Risk in Python: Panic States and Volatility Scaling

The crash literature describes momentum strategies that can experience infrequent and persistent strings of negative returns. For quant traders and data scientists who maintain momentum pipelines, the risk that matters is those persistent strings of losses, not single bad days.
This is a methodology walkthrough, not investment advice. It summarizes the crash-risk argument in Daniel & Moskowitz, “Momentum Crashes” (NBER WP 20439), points to where real momentum factor data lives, and builds a Python sketch that flags panic-like states and volatility-scales a synthetic momentum series.
All code below runs on seeded synthetic data only. No real-data backtest is performed.
What momentum crash risk is
Daniel and Moskowitz describe momentum strategies that “can experience infrequent and persistent strings of negative returns.” The word “persistent” is the design constraint for a pipeline: a winsorizer that clips one outlier day does not address a run of losses.
The same abstract says these “momentum crashes are partly forecastable.” That is a claim about conditioning information, not perfect timing. For an ML engineer, it suggests a low-dimensional market-state feature that modulates exposure, rather than a separate alpha signal.
The abstract gives no crash magnitudes or dates, and the full text was not retrieved for this post, so no figure from the paper body appears here. The published version is in the Journal of Financial Economics, vol 122(2), 2016, pp. 221-247 (DOI 10.1016/j.jfineco.2015.12.002), as listed on the NBER page.
The panic-state signature
The abstract places crashes in “‘panic’ states - following market declines and when market volatility is high - and are contemporaneous with market rebounds.”
Each condition maps to a feature:
- Following market declines. A trailing drawdown from a recent peak is a natural state variable. The window length is a design choice. This demo uses 252 trading days.
- When market volatility is high. Direction alone is not enough. A decline on low volatility is a different state from a decline with expanding realized volatility, so the flag should combine both.
- Contemporaneous with market rebounds. The abstract says crashes coincide with rebounds, so momentum should not be assumed to diversify in those states. A risk report that treats momentum as market-neutral in every regime will understate this tail.
In this post’s reading, a decline plus elevated volatility identifies a higher-risk state. It does not tell you the rebound day in advance.
Momentum data and a format gotcha
For real momentum factors, the standard starting point is the Kenneth R. French Data Library, which lists Momentum Factor (Mom) downloads in monthly and daily forms.
Check the format before you append new files to an old store. The library page states that since the January 2025 release, US research returns use CRSP Stock and Indexes Flat File Format 2.0 (CIZ). In that format, monthly returns are compounded daily returns with dividends reinvested on ex-dates. The legacy FIZ format reinvested at month-end.
That means monthly returns before and after the switch are not like-for-like. Concatenating files across the boundary can introduce a seam in compounding and dividend timing. Keep raw vintages, record each file’s format, and do not mix formats in one return series without an explicit adjustment note. The page links a legacy archive for pre-switch files.
This post does not download those files. The code uses only synthetic returns.
Python sketch: flag panic states, scale exposure
The script uses numpy and pandas only, with a fixed seed. It generates seven years of business-day synthetic market and momentum returns and injects one panic-plus-rebound episode: the market falls on high volatility, then rebounds while synthetic momentum has a negative mean.
Three design choices matter:
- Lags. The panic flag and the momentum-volatility input to the scale are shifted one day, so the flag and the scale on day t use only information available at t-1.
- No leverage. The volatility scale is capped at 1.0.
- Illustrative rule. The scaling is a generic target-volatility rule with a panic-state halving. The paper’s dynamic weight formula is not in the abstract, so this is not the authors’ strategy and not a replication.
import numpy as np
import pandas as pd
print("=== SYNTHETIC DATA ONLY: no real momentum data, no real backtest ===")
rng = np.random.default_rng(42)
dates = pd.date_range("2016-01-04", "2022-12-30", freq="B")
n = len(dates)
# Baseline synthetic daily returns
mkt = rng.normal(0.00035, 0.009, size=n)
mom = rng.normal(0.00030, 0.008, size=n)
# Injected panic (market falls, volatility high) then rebound (market up, momentum negative)
panic_start = int(n * 0.55)
panic_end = int(n * 0.62)
rebound_end = int(n * 0.68)
mkt[panic_start:panic_end] = rng.normal(-0.0035, 0.022, size=panic_end - panic_start)
mom[panic_start:panic_end] = rng.normal(-0.0005, 0.018, size=panic_end - panic_start)
mkt[panic_end:rebound_end] = rng.normal(0.0040, 0.015, size=rebound_end - panic_end)
mom[panic_end:rebound_end] = rng.normal(-0.0045, 0.016, size=rebound_end - panic_end)
df = pd.DataFrame({"mkt": mkt, "mom": mom}, index=dates)
# State features: drawdown from the trailing 252-day peak, annualized realized vols
mkt_cum = (1 + df["mkt"]).cumprod()
df["mkt_dd"] = mkt_cum / mkt_cum.rolling(252, min_periods=1).max() - 1.0
df["mkt_vol"] = df["mkt"].rolling(21).std() * np.sqrt(252)
df["mom_vol"] = df["mom"].rolling(21).std() * np.sqrt(252)
vol_median = df["mkt_vol"].rolling(252, min_periods=63).median()
# Panic flag: in a drawdown AND market vol above its own trailing median.
# shift(1): day t is flagged using only information available at t-1.
raw_flag = (df["mkt_dd"] < -0.08) & (df["mkt_vol"] > vol_median)
df["panic_flag"] = raw_flag.shift(1, fill_value=False).astype(int)
# Illustrative volatility scaling: target vol / lagged momentum vol, capped at 1.0 (no leverage),
# halved while flagged. The paper's dynamic weight formula is NOT used here.
target_vol = 0.15
scale = (target_vol / df["mom_vol"].shift(1).clip(lower=0.05)).clip(upper=1.0)
scale = scale.where(df["panic_flag"] == 0, scale * 0.5).fillna(1.0)
df["scale"] = scale
df["mom_scaled"] = df["mom"] * df["scale"]
def max_drawdown(ret):
cum = (1 + ret.fillna(0)).cumprod()
return (cum / cum.cummax() - 1.0).min()
summary = pd.DataFrame({
"mean_daily": [df["mom"].mean(), df["mom_scaled"].mean()],
"daily_vol": [df["mom"].std(), df["mom_scaled"].std()],
"worst_day": [df["mom"].min(), df["mom_scaled"].min()],
"max_drawdown": [max_drawdown(df["mom"]), max_drawdown(df["mom_scaled"])],
}, index=["static_synth_mom", "scaled_synth_mom"])
first = int(np.flatnonzero(df["panic_flag"].to_numpy())[0])
print(f"panic-flagged days: {int(df['panic_flag'].sum())} of {len(df)}")
print(f"first flagged date: {df.index[first].date()}")
inside = int(df["panic_flag"].iloc[panic_start:rebound_end].sum())
print(f"flags inside injected episode: {inside} of {rebound_end - panic_start} days; outside: {int(df['panic_flag'].sum()) - inside}")
print("flag sample (2 days before to 2 days after first flag):")
print(df[["mkt_dd", "mkt_vol", "panic_flag", "scale"]].iloc[first - 2:first + 3].round(4))
print("summary (synthetic):")
print(summary.round(6))
Reading the output: what the demo shows and what it cannot
Running the script on the seed above prints:
- 565 panic-flagged days out of 1,825.
- 157 of the 238 days inside the injected episode are flagged, and 408 flagged days fall outside it.
- Static synthetic momentum: mean daily return -0.000209, daily volatility 0.009704, worst day -0.047753, max drawdown -0.645997.
- Scaled synthetic momentum: mean daily return 0.000081, daily volatility 0.007163, worst day -0.034444, max drawdown -0.345687.
The flag over-fires. On this path it marks 408 days outside the stress window, starting in June 2016, so it is a poor detector. The useful lesson is calibration: a rule built from a fixed drawdown cutoff and a trailing-median volatility test will flag ordinary noise unless you test its false-positive rate on data without a stress episode. Before using any such flag, measure the share of flagged days in calm periods.
The scaled series shows lower volatility and a shallower drawdown on this seed. That reflects the rule’s exposure cut on a synthetic path, not evidence about momentum. The printed numbers are synthetic and cannot support claims about real alpha, Sharpe ratios, or crash sizes.
The paper’s own result, as its abstract states, is that “an implementable dynamic momentum strategy based on forecasts of momentum’s mean and variance approximately doubles the alpha and Sharpe Ratio of a static momentum strategy, and is not explained by other factors.” That is the authors’ reported claim. This post does not estimate alpha or test other factors.
Caveats, disclosure, and further reading
First, format consistency matters once you use real factors. Version your downloads from the French Data Library, keep the legacy archive for older work, and record whether each series uses the monthly or daily Mom file.
Second, conflict disclosure. The NBER page for the paper notes that Moskowitz has an academic consulting relationship with AQR Capital, which invests in momentum strategies. Readers evaluating momentum research should weigh that.
Third, scope. This is educational methodology. It is not a trading recommendation and contains no real-data performance result. Before drawing conclusions from any extension, handle point-in-time data, transaction costs, turnover, and shorting constraints.
FAQ
What is a momentum crash?
The paper describes momentum strategies that suffer “infrequent and persistent strings of negative returns,” which the authors say are “partly forecastable.” The risk is in the persistence, not in any one day.
Why would volatility scaling help momentum?
The abstract places crashes in high-volatility states that follow market declines. A rule that lowers exposure in those states reduces exposure when the paper says losses concentrate. The paper reports that its dynamic strategy approximately doubles the alpha and Sharpe ratio of static momentum, a result this post does not verify.
Can I run this code on real momentum data?
You can adapt the drawdown and volatility logic to the French library’s monthly and daily Mom files. Account for the CIZ versus FIZ reinvestment change in January 2025, and measure the flag’s false-positive rate on calm periods first. The script in this post stays on seeded synthetic data.
← Back to all posts

