liveBook · Manning

Arch_model

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

arch_model is a Python API function in the arch library that constructs ARCH-family volatility models.

arch_model constructs an ARCH-family volatility model from return data. It is useful when volatility clusters during crises and later mean-reverts toward earlier levels. section 3.2.2

A practical workflow is:

  • Compute percentage returns, multiply them by 100 for more reliable optimizer convergence, and remove the initial NaN. section 3.2.2
  • Construct arch_model(returns), fit it, and request a forecast horizon such as 63 trading days. section 3.2.2
  • Read residual_variance forecasts and sum, annualize, and rescale them to obtain a volatility forecast. section 3.2.2
Listing 3.9 Using a GARCH model to forecast volatility
from arch import arch_model

AAPL_prices = yf.download('AAPL', start='2000-01-03', end='2022-05-24')['Adj 
Close']
returns = 100 * AAPL_prices.pct_change().dropna()  #1

horizon = 63  #2
am = arch_model(returns)  #3
res = am.fit()  #4
forecasts = res.forecast(horizon=horizon)  #5
print(forecasts.residual_variance.iloc[-1,:])  #6

The complete AAPL example shows importing arch_model, preparing returns, fitting the model, and forecasting 63 horizons. section 3.2.2

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

How deep it goes
Demonstrates return preparation, model fitting, multi-day forecasting, and annualization while deferring more complex parameter choices.
Examples
Uses AAPL prices, scaled percentage returns, a 63-day horizon, and a resulting volatility forecast of 0.4810.
What it assumes
Assumes price data and percentage-return preparation while teaching scaling and missing-value handling for estimation.
What you can do after
Apply it via Python to fit a volatility model and produce annualized multi-day volatility forecasts.
How it connects
Connects volatility clustering, mean reversion, returns, variance forecasts, and GARCH models.

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.