Skip to main content

ARCH for Python

Project description

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
Anaconda-Server Badge
Continuous Integration Build Status
Appveyor Build Status
Coverage Coverage Status
codecov
Code Quality Code Quality: Python
Total Alerts
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

Released documentation is hosted on read the docs. Current documentation from the master branch is hosted on my github pages.

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.

import datetime as dt
import pandas_datareader.data as web
st = dt.datetime(1990,1,1)
en = dt.datetime(2014,1,1)
data = web.get_data_yahoo('^FTSE', start=st, end=en)
returns = 100 * data['Adj Close'].pct_change().dropna()

from arch import arch_model
am = arch_model(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.

# Import data
import datetime as dt
import pandas as pd
import numpy as np
import pandas_datareader.data as web
start = dt.datetime(1951,1,1)
end = dt.datetime(2014,1,1)
sp500 = web.get_data_yahoo('^GSPC', start=start, end=end)
start = sp500.index.min()
end = sp500.index.max()
monthly_dates = pd.date_range(start, end, freq='M')
monthly = sp500.reindex(monthly_dates, 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.conf_int(sharpe_ratio, 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.

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
cov_est.cov.long_run

Requirements

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

  • Python (3.7+)
  • NumPy (1.16+)
  • SciPy (1.2+)
  • Pandas (0.23+)
  • statsmodels (0.11+)
  • matplotlib (2.2+), optional
  • property-cached (1.6.4+), optional

Optional Requirements

  • Numba (0.35+) will be used if available and when installed using the --no-binary option
  • 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.

pip install arch

This command should work whether you have a compiler installed or not. If you want to install with the --no-binary options, use

pip install arch --install-option="--no-binary" --no-build-isoloation

The --no-build-isoloation uses the existing NumPy when building the source. This is usually needed since pip will attempt to build all dependencies from source when --install-option is used.

You can alternatively install the latest version from GitHub

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

--install-option="--no-binary" --no-build-isoloation can be used to disable compilation of the extensions.

Anaconda

conda users can install from my channel,

conda install arch -c bashtage

Windows

Building extension using the community edition of Visual Studio is well supported for Python 3.6+. Building on other combinations of Python/Windows is more difficult and 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 --no-binary)
  • pytest (For tests)
  • sphinx (to build docs)
  • sphinx_material (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 --no-binary was used.
  2. Setup does not verify these requirements. Please ensure these are installed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arch-4.16.1.tar.gz (862.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

arch-4.16.1-cp39-cp39-win_amd64.whl (777.2 kB view details)

Uploaded CPython 3.9Windows x86-64

arch-4.16.1-cp39-cp39-win32.whl (751.0 kB view details)

Uploaded CPython 3.9Windows x86

arch-4.16.1-cp39-cp39-manylinux1_x86_64.whl (794.9 kB view details)

Uploaded CPython 3.9

arch-4.16.1-cp39-cp39-manylinux1_i686.whl (784.1 kB view details)

Uploaded CPython 3.9

arch-4.16.1-cp39-cp39-macosx_10_9_x86_64.whl (790.4 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

arch-4.16.1-cp38-cp38-win_amd64.whl (777.8 kB view details)

Uploaded CPython 3.8Windows x86-64

arch-4.16.1-cp38-cp38-win32.whl (751.6 kB view details)

Uploaded CPython 3.8Windows x86

arch-4.16.1-cp38-cp38-manylinux1_x86_64.whl (796.2 kB view details)

Uploaded CPython 3.8

arch-4.16.1-cp38-cp38-manylinux1_i686.whl (784.7 kB view details)

Uploaded CPython 3.8

arch-4.16.1-cp38-cp38-macosx_10_9_x86_64.whl (787.4 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

arch-4.16.1-cp37-cp37m-win_amd64.whl (774.8 kB view details)

Uploaded CPython 3.7mWindows x86-64

arch-4.16.1-cp37-cp37m-win32.whl (748.3 kB view details)

Uploaded CPython 3.7mWindows x86

arch-4.16.1-cp37-cp37m-manylinux1_x86_64.whl (798.9 kB view details)

Uploaded CPython 3.7m

arch-4.16.1-cp37-cp37m-manylinux1_i686.whl (787.6 kB view details)

Uploaded CPython 3.7m

arch-4.16.1-cp37-cp37m-macosx_10_9_x86_64.whl (788.6 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

Details for the file arch-4.16.1.tar.gz.

File metadata

  • Download URL: arch-4.16.1.tar.gz
  • Upload date:
  • Size: 862.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/51.3.3.post20210118 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

File hashes

Hashes for arch-4.16.1.tar.gz
Algorithm Hash digest
SHA256 0b3dd394f3f9d09b2ca1cb1027700fa2fcc678873242daec39a66b7988b964e3
MD5 43058eb66f7bbbef38b7c28640d6b734
BLAKE2b-256 d022e12e588309552a0ba8a47b7a5dbbbe19bb3abcb07f2090a73d7ccddff0d1

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: arch-4.16.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 777.2 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for arch-4.16.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1b4dfef12a5c0d8af591f7728d4d06808975d543e1afd8cb04c14ecd404992d5
MD5 2f427b59226812e5fc67f64bb98ff045
BLAKE2b-256 0a1e088703c067cd7bd04de784488b86007fac1cce0fa0eae1c157e66c6db2e8

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp39-cp39-win32.whl.

File metadata

  • Download URL: arch-4.16.1-cp39-cp39-win32.whl
  • Upload date:
  • Size: 751.0 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for arch-4.16.1-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 352190d17a81f91aa894804f191d6390c8d62f18c18cac4c1107a80613ad7319
MD5 5807d27773313ab7e1ad009d03104a99
BLAKE2b-256 25bfd55d1a9a43a3516eae2628f98085b151d952c8fbb2fa0f13489e2fbdd183

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: arch-4.16.1-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 794.9 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for arch-4.16.1-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3ea6e6d8a7435a2e5684522af1bcd0e6e62befd421f40fb7f8306b51f6292ac3
MD5 8043cd1091f74c6bf61c60d85009140b
BLAKE2b-256 db2e807941b4ccf1255292aeaf31b251414c1fff771f6586239ef0021634b3bd

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp39-cp39-manylinux1_i686.whl.

File metadata

  • Download URL: arch-4.16.1-cp39-cp39-manylinux1_i686.whl
  • Upload date:
  • Size: 784.1 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for arch-4.16.1-cp39-cp39-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5700a9d3b344030bdec2c4db9434f1cc9614bc6a1be7072bbed09060158a9a43
MD5 bb5f9e564d722b247e77b80269d7e4a9
BLAKE2b-256 996d3ba79a572cfffb858a30dddea9d4610d968fccb067647f58531416359269

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: arch-4.16.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 790.4 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for arch-4.16.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 203a8a2599d81d339a1d6efc26a4315311b316c941fab1688feb23e8fb3859c5
MD5 d80ea215ace3232978d3524df9e28a53
BLAKE2b-256 a023acc19c2bab935e48e41d22e79192830f2c0465669c3f8f6b2443c64bd30a

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: arch-4.16.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 777.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.0

File hashes

Hashes for arch-4.16.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 a42ecd48b899fb088b523011090a799544b2e283aff3c1cdb7a3e3cf1da8969e
MD5 5a1e4f3bc813293215ee687616964b6f
BLAKE2b-256 514a165d681bba9c3881c8012be8bcace915e5d3f923cd0d1d89a60ecaeb147a

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp38-cp38-win32.whl.

File metadata

  • Download URL: arch-4.16.1-cp38-cp38-win32.whl
  • Upload date:
  • Size: 751.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.0

File hashes

Hashes for arch-4.16.1-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 fe282a90102f4b9d960f068446456efd740311dcf99531abe82c3e33b62348af
MD5 7724fdac8b854e8cbfd06aec1ba4ac19
BLAKE2b-256 b313c5bbedc9f9e7538db8df19b140195f28a0d9e9f09a6cf8803a9af30e80b5

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: arch-4.16.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 796.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for arch-4.16.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 83d3a963fa6779a545828eca7d6dfbb6fb28b7433c5f4c0319cd4c1825d6de18
MD5 7083408e449f7bd1c9018b8c78d508a7
BLAKE2b-256 9c4bf522e5daac53b871982bfa12ea663185051fc33ae6102e8d0fd0ef6d346f

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: arch-4.16.1-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 784.7 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for arch-4.16.1-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b0e3a534f52b0bbc0563ae6d2bc5c9d340c9ea58e403684b3cd5868f1eebe9b7
MD5 8969796133cf77d259fad6d3f54b1a0e
BLAKE2b-256 7d74c25e5b1ff9e556baa4963bb96a02d751e92b518f9a9fc22fbb52f84b3daf

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: arch-4.16.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 787.4 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for arch-4.16.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ed580c6de01c71b447c822da4656a282d2c6f44abe8cb948bf7790c877381d97
MD5 403abcb1ca9e0e7c39c3d06b2bbc81e2
BLAKE2b-256 1931993b738497978b31de588e78bdb0cd0c28d1bed3d50f91bea116d0e12f83

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: arch-4.16.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 774.8 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.5

File hashes

Hashes for arch-4.16.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4ae88fd79c6070d8c5ea7873b5372e3ade3ba9f401a2e6a6c19f21dc8d28d036
MD5 ce2d86642dc3ae5e2d7a618e719f981d
BLAKE2b-256 9da56d352db1d91e76e763de2b84992ee5d693b07c4bb86ec4757b51be4c6d99

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp37-cp37m-win32.whl.

File metadata

  • Download URL: arch-4.16.1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 748.3 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.5

File hashes

Hashes for arch-4.16.1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 2865d60fed1669bc30e731f3dbc51c94ab32df232a2eee8c872382322d815a99
MD5 8d59ef36ec8df574b528b8b31e5752f5
BLAKE2b-256 3463f97d674fc291d459420478ae3811ed5a25907107989b421660f8d6dc14f0

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: arch-4.16.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 798.9 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for arch-4.16.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 27a20ab5d9c9ad1a220b1ee5b01f80537b4d920829c21855beea2b04530fa1ba
MD5 39df95975ba45edbe059586bbca18e25
BLAKE2b-256 9eb189c64c5b07d3d15b121c5d6b990cf8df6bd690ba09eb0c5e34487289e2f5

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: arch-4.16.1-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 787.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for arch-4.16.1-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 06a32f953ed37279754c57f5cee6f712b8bd296b98e13e8db0dd01239f56f871
MD5 ab685dfe39a7570eee71da561172d67d
BLAKE2b-256 b3e4f4a2fed13c1647a5a43da9649c57fb0319ab08cb14b4ac43058183ee03e6

See more details on using hashes here.

File details

Details for the file arch-4.16.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: arch-4.16.1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 788.6 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for arch-4.16.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 80a704da21c06bf37c0125da67d4a8eb69c5304461bedc4f1ce42e44778e060a
MD5 4e60660d23935e6216431b37821c8353
BLAKE2b-256 a958b5889e5a453f82b54272f7e9c4f96ed50722da2b4875753973c006341e53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page