🧠 Quantitative Volatility Modeling Using ARCH, GARCH & EWMA This repository contains a detailed implementation of volatility forecasting techniques used in quantitative finance. The models used are:
ARCH (Autoregressive Conditional Heteroskedasticity)
GARCH (Generalized ARCH)
EWMA (Exponentially Weighted Moving Average)
You’ll also find real vs. predicted volatility comparison, full Python code (in Jupyter Notebook), and step-by-step implementation.
📁 Files Included File Name Description volatilitymodeling.ipynb Main Jupyter Notebook implementing ARCH, GARCH, and EWMA models on JPMorgan stock data
📌 Table of Contents
- Project Objective
- Data Source
- ARCH Model
- GARCH Model
- EWMA Model
- Realized vs Predicted Volatility
- Libraries Used
- How to Run
- Conclusion
To model and forecast the volatility of JPMorgan Chase (JPM) stock returns using time-series econometric techniques, and to compare predicted volatility with actual realized market volatility.
Two data sources are used for price information:
- Yahoo Finance via the
yfinance
Python API
Date Range: 2015-01-01 to 2025-01-01 Stock Ticker: JPM (JPMorgan Chase)
The ARCH (1) model assumes that today's volatility depends on the squared return from the previous day.
Where:
-
$\omega$ is the long-term base level of variance -
$\alpha_1$ is the coefficient on yesterday's squared return
- Calculate daily returns
- Fit ARCH(1) using
arch_model
from thearch
package - Forecast 5-day ahead variance
- Convert to volatility (sqrt of variance)
- Compare with 5-day realized volatility
Predicted Volatility (5-day): ~1.56%
Realized Volatility (5-day): ~1.69%
The GARCH(1,1) model extends ARCH by including past variance in addition to past squared returns. It captures volatility clustering better than ARCH.
Where:
-
$\omega$ : base variance -
$\alpha_1$ : impact of last return shock -
$\beta_1$ : impact of past variance
- Calculate daily returns
- Fit GARCH(1,1) using
arch_model
- Forecast 5-day volatility horizon
- Compare with actual volatility of that period
Predicted Volatility (5-day): ~1.62%
Realized Volatility (5-day): ~1.69%
EWMA estimates volatility by assigning exponentially decreasing weights to past squared returns. It's widely used due to its simplicity and responsiveness to recent data.
Where:
-
$\lambda$ : decay factor (commonly 0.94 for daily data) -
$r^2_{t-1}$ : squared return from previous day -
$\sigma^2_{t-1}$ : previous day’s variance
- Set lambda value (e.g. 0.94)
- Calculate variance recursively from return series
- Take square root to get volatility
- Forecast is only for 1 day ahead
Predicted Volatility (2025-01-02): 0.14
Realized Return (absolute): 0.12
Note: Since it's a 1-day forecast, we compare to absolute return instead of standard deviation.
-
Predicted Volatility: Output of ARCH/GARCH/EWMA model
-
Realized Volatility:
- For ARCH/GARCH: std deviation of next 5 daily returns (annualized)
- For EWMA: abs(return on next day)
This comparison helps evaluate model accuracy in practical terms.
pandas
numpy
yfinance
arch
matplotlib
requests
- Install required libraries:
pip install yfinance arch pandas numpy matplotlib
- Open
volatilitymodeling.ipynb
in Jupyter or VS Code - Run all cells
This project demonstrates how to:
- Apply volatility models on real-world stock data
- Compare predicted vs actual market movements
- Understand the dynamics of conditional heteroskedasticity in finance
Useful for:
- Quantitative finance enthusiasts
- Students of econometrics
- Risk analysts and traders
Feel free to fork, star, or contribute!