- Conditional Volatility (CV) implements the GARCH(1,1) model for volatility forecasting, the most widely used time-varying volatility model in finan...
Conditional Volatility (CV) implements the GARCH(1,1) model for volatility forecasting, the most widely used time-varying volatility model in financial econometrics. Unlike simple historical volatility measures, GARCH captures two key empirical features of financial returns: volatility clustering (large moves tend to follow large moves) and mean reversion (volatility eventually returns to a long-run average). The output is annualized volatility expressed as a percentage.
## Historical Context
Robert Engle introduced ARCH (Autoregressive Conditional Heteroskedasticity) in 1982, earning him the 2003 Nobel Prize in Economics. Tim Bollerslev generalized this to GARCH (Generalized ARCH) in 1986. The GARCH(1,1) specification—with one lag of squared returns and one lag of variance—became the workhorse model because it captures the essential dynamics while remaining parsimonious.
The key insight was that volatility is not constant over time but evolves predictably. A large price shock today increases tomorrow's expected volatility, which then decays gradually back to the long-run level. This "persistence" in volatility is captured by the β coefficient, while the immediate reaction to shocks is captured by α.
Traditional implementations require maximum likelihood estimation to fit parameters to historical data. This implementation takes a different approach: it uses the warmup period to estimate the long-run variance, then applies user-specified α and β coefficients. This makes the indicator immediately usable without optimization, while still capturing the essential GARCH dynamics.
## Architecture & Physics
### 1. Log Return Calculation
Returns are computed as continuously compounded (log) returns:
$$
r_t = \ln\left(\frac{C_t}{C_{t-1}}\right)
$$
where:
- $C_t$ = closing price at time $t$
- $r_t$ = log return at time $t$
Extreme returns are clamped to ±20% to prevent numerical instability from outliers.
1.**Stationarity violation**: Ensure $\alpha + \beta < 1$. The constructor enforces this constraint. Values near 1.0 produce extreme persistence.
2.**Parameter selection**: Default $\alpha = 0.2$, $\beta = 0.7$ are reasonable starting points. Higher α = more reactive to shocks; higher β = more persistent.
3.**Warmup period**: The `period` parameter determines how many observations are used to estimate long-run variance. Too short = noisy estimate; too long = slow to initialize. Default 20 is reasonable for daily data.
4.**Not a forecast**: The output is the *current* conditional variance, not a prediction. For forecasting, the expected variance $h$ days ahead is:
5.**Memory footprint**: Minimal—only stores previous variance and previous close. No rolling buffers required.
6.**Annualization assumption**: Uses 252 trading days. For crypto (365 days) or other markets, the annualization factor may need adjustment in the calling code.
## References
- Engle, R. F. (1982). "Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation." *Econometrica*, 50(4), 987-1007.
- Bollerslev, T. (1986). "Generalized Autoregressive Conditional Heteroskedasticity." *Journal of Econometrics*, 31(3), 307-327.
- Engle, R. F. (2001). "GARCH 101: The Use of ARCH/GARCH Models in Applied Econometrics." *Journal of Economic Perspectives*, 15(4), 157-168.
- Hansen, P. R., & Lunde, A. (2005). "A Forecast Comparison of Volatility Models: Does Anything Beat a GARCH(1,1)?" *Journal of Applied Econometrics*, 20(7), 873-889.