arch: ARCH for Python

8.0.0 · active · verified Sun Apr 12

ARCH is a Python library providing tools for financial econometrics, focusing on Autoregressive Conditional Heteroskedasticity (ARCH) models, unit root tests, cointegration analysis, and bootstrapping. It is actively developed with regular releases, with the current version being 8.0.0, requiring Python 3.10 or newer for optimal compatibility and performance.

Warnings

Install

Imports

Quickstart

This example demonstrates how to fetch historical financial data, calculate returns, and then use `arch_model` to specify and fit a GARCH(1,1,1) model with a Student's T distribution. It prints a summary of the fitted model. Note that `pandas_datareader` is used for data fetching and needs to be installed separately.

import datetime as dt
import pandas_datareader.data as web
from arch import arch_model

# Fetch financial data (example: FTSE 100 index)
# Requires 'pandas_datareader' to be installed (pip install pandas_datareader)
st = dt.datetime(1990,1,1)
en = dt.datetime(2014,1,1)
data = web.DataReader('^FTSE', 'yahoo', start=st, end=en)
returns = 100 * data['Adj Close'].pct_change().dropna()

# Initialize and fit an ARCH model
am = arch_model(returns, vol='Garch', p=1, o=1, q=1, dist='StudentsT')
res = am.fit(update_freq=5)
print(res.summary())

view raw JSON →