How well do classic models (EWMA, the GARCH family, HAR) predict day-to-day risk in the S&P 500? Three notebooks compare their forecasts on ~8.5 years of unseen data (2000 → today), then test whether the forecasts hold up as risk models — including the case where the best forecaster fails the risk test.
| Notebook | Question it answers |
|---|---|
01_stylized_facts.ipynb |
What does S&P 500 volatility look like? Extreme days are far more common than a normal distribution predicts, calm and turbulent periods come in streaks, and drops raise volatility more than rallies. |
02_volatility_models.ipynb |
Which model predicts tomorrow's variance best? A walk-forward contest: each model sees only past data, is re-fit monthly, and is scored out of sample. |
03_var_backtesting.ipynb |
Do the forecasts work as risk models? Each becomes a one-day Value-at-Risk limit, and coverage tests check whether losses breach it as rarely as they should. |
- Bad news moves volatility more than good news. Models that treat drops and rallies differently (GJR, EGARCH) forecast significantly better than symmetric GARCH (p < 0.01).
- The best forecaster fails the risk test. HAR wins the forecasting contest, but its high–low range data misses overnight gaps, so its risk limits are breached ~9% of days instead of the target 5%. One scaling constant, estimated without look-ahead, closes the gap.
- Textbook distributions underestimate the worst days. Normal and Student-t both produce too many breaches at the 1% level over a window containing the 2018 "volmageddon", COVID and 2022.
- Filtered historical simulation fixes the tail — setting the risk limit from the model's own past errors instead of a formula. GJR-t + FHS is the only setup that passes every coverage test at every level.
Daily ^GSPC prices via yfinance
(cached in data/, git-ignored). One-day-ahead variance forecasts, parameters
re-fit every 21 trading days on an expanding window — no forecast uses
information from its own day or later. Forecasts are scored against the
Parkinson high–low range proxy with QLIKE loss and compared via
Diebold–Mariano tests; VaR is backtested with the Kupiec and Christoffersen
coverage tests.
Requires uv.
git clone https://github.com/bartox12/volatility-forecasting.git
cd volatility-forecasting
uv sync
uv run jupyter lab notebooks/Run the notebooks in order — 02 writes the forecasts that 03 consumes.
Price data downloads automatically on first use.
├── notebooks/ three-part narrative analysis
├── src/volatility/ reusable package
│ ├── data.py yfinance loader, log returns, Parkinson variance
│ ├── stats.py stylized-facts diagnostics
│ ├── models.py EWMA, GARCH wrappers, HAR, losses, Diebold–Mariano
│ ├── backtest.py VaR construction, Kupiec & Christoffersen tests
│ └── plotting.py shared style
├── figures/ exported figures used in this README
└── pyproject.toml uv-managed environment
Parkinson (1980) · Bollerslev (1986) · Glosten, Jagannathan & Runkle (1993) · Kupiec (1995) · Diebold & Mariano (1995) · Christoffersen (1998) · Barone-Adesi, Giannopoulos & Vosper (1999) · Corsi (2009) · Patton (2011)

