liveBook · Manning

GARCH model

As explained in Build a Robo-Advisor with Python (From Scratch)

A generalized autoregressive conditional heteroskedasticity model estimates time-varying conditional volatility from past observations and volatility shocks.

A GARCH model forecasts time-varying volatility when returns show volatility clustering and volatility mean reversion. It is useful for estimating asset variances and improving portfolio inputs. section 3.2.2 section 3.0

A practical volatility-forecasting workflow:

  • Download adjusted prices and compute percentage returns, dropping the initial missing value. section 3.2.2
  • Scale returns by 100 so the ARCH-library optimization is more likely to converge. section 3.2.2
  • Fit an arch_model and forecast a chosen horizon; interpret each output as a one-day variance forecast. section 3.2.2
  • Sum the horizon’s daily variances and annualize with 252 divided by the forecast horizon before taking the square root. section 3.2.2

AAPL three-month forecast

Using adjusted AAPL prices, a 63-trading-day forecast produces declining one-day variances from 9.8718 to 9.2234. Summing and annualizing them gives a volatility forecast of 0.4810 after undoing the return scaling. section 3.2.2

Table 3.9 S&P500 returns around the stock market crash of 1987
Date Close % Change
1987-10-08 314.160004 -1.375025
1987-10-09 311.070007 -0.983574
1987-10-12 309.390015 -0.540069
1987-10-13 314.519989 1.658093
1987-10-14 305.230011 -2.9537
1987-10-15 298.079987 -2.342504
1987-10-16 282.700012 -5.15968
1987-10-19 224.839996 -20.466931
1987-10-20 236.830002 5.332684
1987-10-21 258.380005 9.099355
1987-10-22 248.250000 -3.920584
1987-10-23 248.220001 -0.012084
1987-10-26 227.669998 -8.278947
1987-10-27 233.190002 2.424564
1987-10-28 233.279999 0.038594
1987-10-29 244.770004 4.925414
1987-10-30 251.789993 2.867994

The 1987 S&P 500 return sequence provides a concrete view of clustered, unusually large market movements that motivate conditional-volatility models. section 3.2.2

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Explains clustering and mean reversion, then implements fitting, horizon forecasting, variance aggregation, and annualization.
Examples
Uses AAPL prices, a 63-day forecast, and crisis-era S&P 500 returns to demonstrate volatility estimation.
What it assumes
Assumes return and variance calculations, while demonstrating price downloading, missing-value removal, scaling, and forecast interpretation.
What you can do after
Apply it via Python’s arch library to produce annualized multi-day volatility forecasts.
How it connects
Connects volatility clustering, volatility mean reversion, ARCH models, EWMA, implied volatility, and portfolio covariances.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.