https://github.com/bashtage/arch

ARCH models in Python

https://github.com/bashtage/arch

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.6%) to scientific vocabulary

Keywords

adf arch bootstrap df-gls dickey-fuller finance financial-econometrics forecasting garch model-confidence-set multiple-comparison-procedures phillips-perron reality-check risk spa time-series unit-root variance volatility

Keywords from Contributors

econometrics count-model generalized-linear-models hypothesis-testing prediction regression-models robust-estimation timeseries-analysis gmm instrumental-variable
Last synced: 5 months ago · JSON representation

Repository

ARCH models in Python

Basic Info
Statistics
  • Stars: 1,437
  • Watchers: 49
  • Forks: 269
  • Open Issues: 40
  • Releases: 49
Topics
adf arch bootstrap df-gls dickey-fuller finance financial-econometrics forecasting garch model-confidence-set multiple-comparison-procedures phillips-perron reality-check risk spa time-series unit-root variance volatility
Created over 11 years ago · Last pushed 6 months ago
Metadata Files
Readme License

README.md

arch

arch

Autoregressive Conditional Heteroskedasticity (ARCH) and other tools for financial econometrics, written in Python (with Cython and/or Numba used to improve performance)

| Metric | | | :------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Latest Release | PyPI version | | | conda-forge version | | Continuous Integration | Build Status | | Coverage | codecov | | Code Quality | Codacy Badge | | | codebeat badge | | Citation | DOI | | Documentation | Documentation Status |

Module Contents

Python 3

arch is Python 3 only. Version 4.8 is the final version that supported Python 2.7.

Documentation

Documentation from the main branch is hosted on my github pages.

Released documentation is hosted on read the docs.

More about ARCH

More information about ARCH and related models is available in the notes and research available at Kevin Sheppard's site.

Contributing

Contributions are welcome. There are opportunities at many levels to contribute:

  • Implement new volatility process, e.g., FIGARCH
  • Improve docstrings where unclear or with typos
  • Provide examples, preferably in the form of IPython notebooks

Examples

Volatility Modeling

  • Mean models
    • Constant mean
    • Heterogeneous Autoregression (HAR)
    • Autoregression (AR)
    • Zero mean
    • Models with and without exogenous regressors
  • Volatility models
    • ARCH
    • GARCH
    • TARCH
    • EGARCH
    • EWMA/RiskMetrics
  • Distributions
    • Normal
    • Student's T
    • Generalized Error Distribution

See the univariate volatility example notebook for a more complete overview.

```python import datetime as dt import pandasdatareader.data as web st = dt.datetime(1990,1,1) en = dt.datetime(2014,1,1) data = web.getdatayahoo('^FTSE', start=st, end=en) returns = 100 * data['Adj Close'].pctchange().dropna()

from arch import archmodel am = archmodel(returns) res = am.fit() ```

Unit Root Tests

  • Augmented Dickey-Fuller
  • Dickey-Fuller GLS
  • Phillips-Perron
  • KPSS
  • Zivot-Andrews
  • Variance Ratio tests

See the unit root testing example notebook for examples of testing series for unit roots.

Cointegration Testing and Analysis

  • Tests
    • Engle-Granger Test
    • Phillips-Ouliaris Test
  • Cointegration Vector Estimation
    • Canonical Cointegrating Regression
    • Dynamic OLS
    • Fully Modified OLS

See the cointegration testing example notebook for examples of testing series for cointegration.

Bootstrap

  • Bootstraps
    • IID Bootstrap
    • Stationary Bootstrap
    • Circular Block Bootstrap
    • Moving Block Bootstrap
  • Methods
    • Confidence interval construction
    • Covariance estimation
    • Apply method to estimate model across bootstraps
    • Generic Bootstrap iterator

See the bootstrap example notebook for examples of bootstrapping the Sharpe ratio and a Probit model from statsmodels.

```python

Import data

import datetime as dt import pandas as pd import numpy as np import pandasdatareader.data as web start = dt.datetime(1951,1,1) end = dt.datetime(2014,1,1) sp500 = web.getdatayahoo('^GSPC', start=start, end=end) start = sp500.index.min() end = sp500.index.max() monthlydates = pd.daterange(start, end, freq='M') monthly = sp500.reindex(monthlydates, method='ffill') returns = 100 * monthly['Adj Close'].pct_change().dropna()

Function to compute parameters

def sharpe_ratio(x): mu, sigma = 12 * x.mean(), np.sqrt(12 * x.var()) return np.array([mu, sigma, mu / sigma])

Bootstrap confidence intervals

from arch.bootstrap import IIDBootstrap bs = IIDBootstrap(returns) ci = bs.confint(sharperatio, 1000, method='percentile') ```

Multiple Comparison Procedures

  • Test of Superior Predictive Ability (SPA), also known as the Reality Check or Bootstrap Data Snooper
  • Stepwise (StepM)
  • Model Confidence Set (MCS)

See the multiple comparison example notebook for examples of the multiple comparison procedures.

Long-run Covariance Estimation

Kernel-based estimators of long-run covariance including the Bartlett kernel which is known as Newey-West in econometrics. Automatic bandwidth selection is available for all of the covariance estimators.

```python from arch.covariance.kernel import Bartlett from arch.data import nasdaq data = nasdaq.load() returns = data[["Adj Close"]].pct_change().dropna()

cov_est = Bartlett(returns ** 2)

Get the long-run covariance

covest.cov.longrun ```

Requirements

These requirements reflect the testing environment. It is possible that arch will work with older versions.

  • Python (3.9+)
  • NumPy (1.19+)
  • SciPy (1.5+)
  • Pandas (1.1+)
  • statsmodels (0.12+)
  • matplotlib (3+), optional

Optional Requirements

  • Numba (0.49+) will be used if available and when installed without building the binary modules. In order to ensure that these are not built, you must set the environment variable ARCH_NO_BINARY=1 and install without the wheel.

shell export ARCH_NO_BINARY=1 python -m pip install arch

or if using Powershell on windows

powershell $env:ARCH_NO_BINARY=1 python -m pip install arch

  • jupyter and notebook are required to run the notebooks

Installing

Standard installation with a compiler requires Cython. If you do not have a compiler installed, the arch should still install. You will see a warning but this can be ignored. If you don't have a compiler, numba is strongly recommended.

pip

Releases are available PyPI and can be installed with pip.

shell pip install arch

You can alternatively install the latest version from GitHub

bash pip install git+https://github.com/bashtage/arch.git

Setting the environment variable ARCH_NO_BINARY=1 can be used to disable compilation of the extensions.

Anaconda

conda users can install from conda-forge,

bash conda install arch-py -c conda-forge

Note: The conda-forge name is arch-py.

Windows

Building extension using the community edition of Visual Studio is simple when using Python 3.8 or later. Building is not necessary when numba is installed since just-in-time compiled code (numba) runs as fast as ahead-of-time compiled extensions.

Developing

The development requirements are:

  • Cython (0.29+, if not using ARCHNOBINARY=1, supports 3.0.0b2+)
  • pytest (For tests)
  • sphinx (to build docs)
  • sphinx-immaterial (to build docs)
  • jupyter, notebook and nbsphinx (to build docs)

Installation Notes

  1. If Cython is not installed, the package will be installed as-if ARCH_NO_BINARY=1 was set.
  2. Setup does not verify these requirements. Please ensure these are installed.

Owner

  • Name: Kevin Sheppard
  • Login: bashtage
  • Kind: user
  • Location: London, UK

GitHub Events

Total
  • Create event: 26
  • Release event: 1
  • Issues event: 4
  • Watch event: 99
  • Delete event: 29
  • Issue comment event: 60
  • Push event: 93
  • Pull request review event: 8
  • Pull request review comment event: 11
  • Pull request event: 63
  • Fork event: 20
Last Year
  • Create event: 26
  • Release event: 1
  • Issues event: 4
  • Watch event: 99
  • Delete event: 29
  • Issue comment event: 60
  • Push event: 93
  • Pull request review event: 8
  • Pull request review comment event: 11
  • Pull request event: 63
  • Fork event: 20

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 707
  • Total Committers: 37
  • Avg Commits per committer: 19.108
  • Development Distribution Score (DDS): 0.214
Past Year
  • Commits: 37
  • Committers: 3
  • Avg Commits per committer: 12.333
  • Development Distribution Score (DDS): 0.054
Top Committers
Name Email Commits
Kevin Sheppard k****d@g****m 556
Kevin Sheppard k****d@t****v 25
Kevin Sheppard k****d@g****m 23
Stanislav Khrapov k****s@g****m 15
Sheppard, Kevin K****d@t****v 12
Gábor Lipták g****k@g****m 11
Rick van Hattem W****h@w****h 6
mikedeltalima m****a@g****m 6
Joren Hammudoglu j****u@g****m 6
alejandro-cermeno 7****o 5
Rob Capellini r****i@g****m 5
snyk-bot s****t@s****o 4
ZWL w****g@g****m 3
Alex Fortin a****n@g****m 2
JPN j****g 2
Matt Judell m****l@p****m 2
Ryan Russell g****t@r****g 2
Weiliang Li t****e@g****m 2
Wu Long w****e@g****m 2
partev p****n@g****m 1
Xin Du d****e@o****m 1
Xavier RENE-CORAIL x****l@g****m 1
Admin a****n@a****e 1
Andreas Knaut a****t@a****e 1
Kevin Sheppard K****d 1
Timothée Gerber t****r@g****r 1
UNO Leo l****2@g****m 1
Tom Rochette r****m@g****m 1
Pavel Krotkov p****v@g****m 1
Nikolay Tretyak n****k 1
and 7 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 50
  • Total pull requests: 214
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 48
  • Total pull request authors: 15
  • Average comments per issue: 3.14
  • Average comments per pull request: 0.89
  • Merged pull requests: 123
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 2
  • Pull requests: 51
  • Average time to close issues: 18 days
  • Average time to close pull requests: 7 days
  • Issue authors: 2
  • Pull request authors: 7
  • Average comments per issue: 10.5
  • Average comments per pull request: 0.71
  • Merged pull requests: 33
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Vasudeva-bit (3)
  • KIC (1)
  • yurivict (1)
  • lfdmotta (1)
  • xuJ14 (1)
  • anthonybritto (1)
  • qgallouedec (1)
  • Alan-Hung (1)
  • luchungi (1)
  • Draenth (1)
  • ssakatausa (1)
  • a412h (1)
  • sitfo-js (1)
  • Eyte123 (1)
  • alfarocesar (1)
Pull Request Authors
  • bashtage (212)
  • snyk-bot (8)
  • partev (3)
  • jorenham (2)
  • pavelkrotkov (2)
  • gavincyi (2)
  • riz0id (1)
  • opoyc (1)
  • lgtm-com[bot] (1)
  • 645775992 (1)
  • wolph (1)
  • RichardMM (1)
  • wday0507 (1)
  • premdev1234 (1)
  • ryanrussell (1)
Top Labels
Issue Labels
enhancement (5) help wanted (2) roadmap (1) bug (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 553,589 last-month
  • Total docker downloads: 1,160
  • Total dependent packages: 35
    (may contain duplicates)
  • Total dependent repositories: 294
    (may contain duplicates)
  • Total versions: 77
  • Total maintainers: 1
pypi.org: arch

ARCH for Python

  • Documentation: https://arch.readthedocs.io/
  • License: # License **Copyright (c) 2017 Kevin Sheppard. All rights reserved.** Developed by: Kevin Sheppard (<kevin.sheppard@economics.ox.ac.uk>, <kevin.k.sheppard@gmail.com>) [https://www.kevinsheppard.com](https://www.kevinsheppard.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. Neither the names of Kevin Sheppard, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. **THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.**
  • Latest release: 7.2.0
    published over 1 year ago
  • Versions: 47
  • Dependent Packages: 33
  • Dependent Repositories: 292
  • Downloads: 553,589 Last month
  • Docker Downloads: 1,160
Rankings
Dependent packages count: 0.6%
Downloads: 0.6%
Dependent repos count: 0.9%
Average: 1.1%
Docker downloads count: 2.2%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/bashtage/arch
  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
conda-forge.org: arch-py

Autoregressive Conditional Heteroskedasticity (ARCH) and other tools for financial econometrics, written in Python (with Cython and/or Numba used to improve performance)

  • Versions: 13
  • Dependent Packages: 2
  • Dependent Repositories: 2
Rankings
Forks count: 11.8%
Stargazers count: 12.2%
Average: 15.9%
Dependent packages count: 19.6%
Dependent repos count: 20.3%
Last synced: 6 months ago

Dependencies

.github/workflows/codeql.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/generate-documentation.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • r-lib/actions/setup-pandoc v2 composite
arch/unitroot/critical_values/simulation/requirements.txt pypi
  • colorama *
  • joblib *
  • psutil *
doc/requirements.txt pypi
  • cython >=0.29.34
  • ipython >=8.0.1
  • jinja2 *
  • jupyter *
  • matplotlib >=3.0
  • nbsphinx *
  • notebook *
  • numpy >=1.22
  • numpydoc >=1.0.0
  • oldest-supported-numpy *
  • pandas >=1.1.0
  • patsy >=0.5.3
  • scipy >=1.5.0
  • seaborn *
  • setuptools >=61
  • setuptools_scm >=7,<8
  • sphinx *
  • sphinx-autodoc-typehints *
  • sphinx-immaterial *
  • statsmodels >=0.13.5
  • wheel *
pyproject.toml pypi
requirements-dev.txt pypi
  • black ==23.3.0 development
  • cython >=0.29.34 development
  • flake8 * development
  • ipython >=7 development
  • isort * development
  • jupyter * development
  • matplotlib >=3 development
  • mypy * development
  • nbconvert * development
  • nbsphinx * development
  • notebook * development
  • numba >=0.49, development
  • oldest-supported-numpy >=2022.11.19 development
  • packaging * development
  • pytest >=7.3 development
  • pytest-cov * development
  • pytest-xdist * development
  • pyupgrade >=3.4.0 development
  • seaborn * development
  • setuptools_scm >=7,<8 development
  • sphinx >=7 development
  • sphinx-autodoc-typehints * development
  • sphinx_immaterial * development
requirements.txt pypi
  • numpy >=1.19
  • pandas >=1.1
  • scipy >=1.5
  • statsmodels >=0.12
setup.py pypi
  • for *
  • str *