๐Ÿšจ Black Swan Risk Indicator

Early-warning system for financial market crises ยท NLP sentiment + ML forecasting + regime detection

๐Ÿ“… Last updated: 2026-05-28 09:12 UTC ๐Ÿ“Š 5 years of data View source on GitHub โ†’

๐ŸŒค๏ธ Today's Market Snapshot

โ˜€๏ธ
Low Risk โ€” Markets in Normal Mode
Low VIX + Trending Bull regime โ†’ standard investment strategies remain viable
๐ŸŒก๏ธ
Current VIX
16.71
โ˜€๏ธ
๐ŸŽญ
Market Regime
๐Ÿ“ˆ Trending Bull
Uptrend โ€” SMA-50 > SMA-200 and low volatility
๐Ÿ“Š
S&P 500
7,520
+4.32% (20 day)

๐ŸŒก๏ธ VIX โ€” The Market Fear Index

  • VIX < 15 = very calm (possibly complacent)
  • VIX 15-20 = normal bull market range
  • VIX 20-30 = investors getting nervous
  • VIX 30-40 = crisis signal (2018 rate hikes, 2022 inflation)
  • VIX > 40 = full crisis โ€” all-time peak: 82.69 (Mar 16, 2020 COVID)
๐Ÿ’ฌ ๐Ÿ’ก How to read: Blue line = actual VIX ยท Dotted orange = 20-day moving average ยท Red star = XGBoost's prediction for VIX 7 trading days from now

๐Ÿ“ˆ VIX history + AI forecast (7-day ahead)

๐Ÿ”ฎ ML Forecast: 7-Day VIX Prediction

๐Ÿ“ˆ
Forecast: VIX rising
Model expects VIX at 18.8 (delta +2.1 from today) โ€” heightened risk monitoring advised
๐Ÿ’ฌ Important caveat: VIX is notoriously difficult to forecast โ€” even academic papers regularly report Rยฒ near zero. Treat this as a directional signal, not a precise number. See accuracy section below for the honest assessment.

๐ŸŽฏ But... How Accurate Is It?

  • Rยฒ (R-squared) = how much better the model explains variance vs predicting the mean
  • Rยฒ = 1.0 = perfect prediction (never happens in practice)
  • Rยฒ = 0 = same as predicting the mean โ€” useless
  • Rยฒ negative = worse than predicting the mean โ€” model is harmful
๐Ÿ’ฌ Model cannot beat the mean prediction โ€” consistent with the Random Walk Hypothesis (Fama, Nobel 2013). Markets contain enough randomness that ML often underperforms simple baselines on volatility forecasting.

โš”๏ธ Model Comparison

  • ๐Ÿ‘ถ Naive baseline: persistence model โ€” predicts "VIX in 7d = VIX today" (no ML)
  • ๐ŸŒฒ XGBoost: gradient-boosted trees, regularized (max_depth=3, n_estimators=100)
  • ๐Ÿ’ก LightGBM: fast tree-based with leaf-wise growth
  • ๐Ÿ“ Ridge: linear regression with L2 regularization
  • ๐Ÿง  LSTM: 1-layer PyTorch LSTM (32 hidden units, dropout 0.2)
๐Ÿฅ‡
Naive
Rยฒ = 0.101
Highest Rยฒ in this evaluation
๐Ÿฅ‰
LSTM
Rยฒ = -3.744
Lowest Rยฒ in this round
๐Ÿ’ฌ Surprise! Naive baseline beats every ML model

The "VIX in 7d = VIX today" model (Rยฒ = 0.101) beats XGBoost, LightGBM, Ridge, and LSTM. This is the Random Walk Hypothesis in finance โ€” asset prices move stochastically, making short-term prediction extremely difficult.

Engineering lesson: Always test naive baselines first. If your ML doesn't beat persistence, don't deploy it.

๐Ÿ” SHAP: What Drives Model Decisions?

  • ๐ŸŽฏ SHAP values derived from Shapley values (Nobel Economics 1953)
  • ๐Ÿ“Š Shows each feature's marginal contribution to a prediction
  • โœ… Fair & consistent โ€” superior to XGBoost's built-in feature_importance
  • ๐Ÿ” Useful for debugging model behavior
๐Ÿ’ฌ Model relies most heavily on SP500_Vol_20D โ€” this is the dominant signal driving predictions

๐ŸŽฌ Animated Timeline

๐Ÿ’ฌ Notice how VIX spikes during every black swan event: Feb 2020 (COVID), Feb 2022 (Russia war), Sep 2022 (Fed rate hikes). This is the recurring pattern we try to detect.

๐ŸŒ 3D Visualization

๐Ÿ’ฌ Observable cluster: red points (high VIX) tend to coincide with days when S&P fell > 3% โ€” confirming the well-known negative correlation between VIX and S&P returns (typically -0.7 to -0.8).

๐Ÿ’ฐ Backtest: Is the Strategy Profitable?

๐Ÿ›ก๏ธ
Black Swan Strategy
1,664,907
Initial $1,000,000 โ†’ +66.5%
Max Drawdown: -28.0%
๐Ÿ“Š
Buy & Hold (baseline)
1,788,811
Initial $1,000,000 โ†’ +78.9%
Max Drawdown: -25.4%

๐Ÿ“ˆ Equity Curve Comparison

๐Ÿ“‰ Which strategy has shallower drawdown?

๐Ÿšจ When did signals fire?

๐Ÿ’ฌ โŒ Strategy underperforms Buy & Hold in this window โ€” because the past 5 years were a bull market, defensive systems sacrifice upside by sitting in cash during rallies.

The strategy's value emerges during actual crises like COVID-2020 or 2008.

๐Ÿงช Paired t-test: Is the strategy significantly better than baseline?

t-statistic
-0.5527
p-value (one-sided)
0.7097
ฮฑ (significance)
0.05
n (daily obs)
1,258
โš ๏ธ Fail to reject Hโ‚€ โ€” insufficient evidence that strategy beats baseline (p โ‰ฅ ฮฑ). Consistent with the Random Walk Hypothesis.

๐ŸŒ Multi-Asset Volatility

๐Ÿ’ฌ Bitcoin's realized volatility is typically 3-5ร— higher than S&P 500. Gold acts as a "safe haven" โ€” often uncorrelated or negatively correlated with equities during crises.

If all assets spike together = systemic risk signal (e.g., COVID-2020, when even gold fell briefly).

๐Ÿ“– Bottom Line

๐ŸŒก๏ธ Today's market
โ˜€๏ธ Trending Bull ยท VIX = 16.71
๐Ÿ”ฎ 7-day forecast
โš ๏ธ VIX expected to rise to 18.8 (+2.1)
๐Ÿ’ก What this system does
An early-warning system for market regime changes. Combines 3 signals: news sentiment (FinBERT) + ML forecast + rule-based crisis detector. It does NOT predict the future with certainty โ€” but it helps reduce drawdowns during crises.
โš ๏ธ Disclaimer
This is an educational and research project โ€” not financial advice. Past performance does not guarantee future results. Markets can stay irrational longer than you can stay solvent.
For engineers / data scientists

๐Ÿ“Š Technical Numbers

  • VIX: 16.71
  • AI Forecast (7d, XGBoost): 18.82
  • Walk-Forward Mean Rยฒ: -0.094 ยฑ 0.571 (5 folds)
  • Best Model (regression): Naive
  • Backtest Sharpe: Strategy 0.74 vs B&H 0.77
  • Max Drawdown: Strategy -28.02% vs B&H -25.43%
  • Transaction cost: 10 bps per turnover
  • Features: 13 (VIX lags, S&P returns, yield curve, gold/oil/DXY)

๐Ÿ“ Methodology

  • Time-series validation: TimeSeriesSplit, no shuffle (no look-ahead bias)
  • FinBERT (ProsusAI) for news sentiment (separate Streamlit app)
  • SHAP TreeExplainer for feature attribution
  • Multi-asset volatility: realized vol 20d annualized (proxy for non-VIX assets)
  • Regime: SMA-50/200 crossover + 20d rolling vol vs historical median

Full source code: github.com/oomNoNe/black-swan-indicator