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
conda-forge version
Continuous Integration Build Status
Appveyor Build Status
Coverage 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 main 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 conda-forge,

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 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.19.tar.gz (874.9 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.19-cp39-cp39-win_amd64.whl (785.6 kB view details)

Uploaded CPython 3.9Windows x86-64

arch-4.19-cp39-cp39-win32.whl (759.5 kB view details)

Uploaded CPython 3.9Windows x86

arch-4.19-cp39-cp39-manylinux1_x86_64.whl (803.4 kB view details)

Uploaded CPython 3.9

arch-4.19-cp39-cp39-manylinux1_i686.whl (792.3 kB view details)

Uploaded CPython 3.9

arch-4.19-cp39-cp39-macosx_10_9_x86_64.whl (798.9 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

arch-4.19-cp38-cp38-win_amd64.whl (786.3 kB view details)

Uploaded CPython 3.8Windows x86-64

arch-4.19-cp38-cp38-win32.whl (760.0 kB view details)

Uploaded CPython 3.8Windows x86

arch-4.19-cp38-cp38-manylinux1_x86_64.whl (804.6 kB view details)

Uploaded CPython 3.8

arch-4.19-cp38-cp38-manylinux1_i686.whl (793.0 kB view details)

Uploaded CPython 3.8

arch-4.19-cp38-cp38-macosx_10_9_x86_64.whl (795.9 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

arch-4.19-cp37-cp37m-win_amd64.whl (783.2 kB view details)

Uploaded CPython 3.7mWindows x86-64

arch-4.19-cp37-cp37m-win32.whl (756.8 kB view details)

Uploaded CPython 3.7mWindows x86

arch-4.19-cp37-cp37m-manylinux1_x86_64.whl (807.1 kB view details)

Uploaded CPython 3.7m

arch-4.19-cp37-cp37m-manylinux1_i686.whl (795.6 kB view details)

Uploaded CPython 3.7m

arch-4.19-cp37-cp37m-macosx_10_9_x86_64.whl (797.1 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: arch-4.19.tar.gz
  • Upload date:
  • Size: 874.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.8

File hashes

Hashes for arch-4.19.tar.gz
Algorithm Hash digest
SHA256 8e005347b4c66f08e72f52c569577518e4c678db377b288aab60c602d8bb9ff2
MD5 3d6e8a233b5b1906cd172fe89c1e1bc9
BLAKE2b-256 6a0fc58da8bbd2ee0ef6562db767f6f28f6f6b6b9fd746360089f2dab48d2c2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 785.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0

File hashes

Hashes for arch-4.19-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b62798768b35b98c32e6479c5f9585a26103d710958a6816dc9beb1d4ee9951b
MD5 785ac2e6d2d6b21d4fc56fc5b87e0c1d
BLAKE2b-256 24b098fa25f12249c4aa435b8981089ec568c3a05e818c3348a74e8ea382e4e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp39-cp39-win32.whl
  • Upload date:
  • Size: 759.5 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0

File hashes

Hashes for arch-4.19-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 44f559ddc038004123ffb3f22dc66b49a2973475d70acf511b94a7255538341c
MD5 0132d52e547f1febf37f2271986ff0e3
BLAKE2b-256 a2e916ff85e4d7881ea0a932aa92e9042e3e09f3321ccc0124032572903f7c58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 803.4 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for arch-4.19-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7c6c9814b741e2fd672a6d9f9bcbcf0a15c824774078f98c3ce524930adb0872
MD5 a10b28ef3bcaaf7ab6212df1202e8b3b
BLAKE2b-256 da0fbdf885a74f28b5baa0615f8b0587d1baad0e785ea4cfe831390a53e50a10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp39-cp39-manylinux1_i686.whl
  • Upload date:
  • Size: 792.3 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for arch-4.19-cp39-cp39-manylinux1_i686.whl
Algorithm Hash digest
SHA256 272b1bf2ca15fc8c484f488fba4881511ea8167b2cf8a7d153c5f5013c6c7a2a
MD5 51362cceaaf49109e569c9f404d0ddd9
BLAKE2b-256 b5d91c920c5e5a40eb553426f57964753b1761feac33b4b5b89c1e2ea76ccabf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 798.9 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for arch-4.19-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bc1e22c7297804a87915846d631290865c1d3d81583d37f9a8a55cc9569902b1
MD5 a09a0890ce4fd33e2e7d9563def694d0
BLAKE2b-256 9270c1441c2a6c5ddfa651882d0b12564c561eb56ce993e1c371c7538d22867f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 786.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.0

File hashes

Hashes for arch-4.19-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e10f252b525f405c263bbd17ae275454e4bde96f06649356561605a9d66f084c
MD5 f990f0d8581b2dac71b0a1613634f052
BLAKE2b-256 f95db88a8d35f9d95921f3a0d865ad98f311039cacc6d554c1a16361e920c3ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp38-cp38-win32.whl
  • Upload date:
  • Size: 760.0 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.0

File hashes

Hashes for arch-4.19-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 3335ce6f4a6fac29cfc8e116380123beabc451264157c7ad240278013dfaf94f
MD5 48a6ff6398aad7b7b1a096b7a207097e
BLAKE2b-256 e71bc1f04dd928a9f55c107b558d8d77434d2160bebbaae3f798f70075718b9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 804.6 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for arch-4.19-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 28df500f413546fc77af6bd77271be49c75e248a4bfcbc64309d9cde7bc47e10
MD5 04757fde647e579cf86d9783482bf317
BLAKE2b-256 b52ce2dc9c5be84af2c28051c195701a0115caf0cbeab812eca3b6ec7bdd6dbf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 793.0 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for arch-4.19-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2bbac3a6dcf0cec193cb041fcfd14a6a827ca116e544515eeaa1434007123637
MD5 51a7f88f6312a6f25e8810fe9faaaebc
BLAKE2b-256 283cd586ab45c42ab68640c057a1411d84984bdc4450d533ebfde1d25d15c092

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 795.9 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for arch-4.19-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7d6e093de7266855f06d64424460aec8108e1968e2728059eaffd80a0032d893
MD5 305c418e74cdbd9ac77980a0242600b9
BLAKE2b-256 d7722523037f7cca4b0fc4a5488dc04945c3ca590edec70b2380d73979541d5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 783.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.5

File hashes

Hashes for arch-4.19-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 590c5c2dae06ae4542dc8d3b5457f3a44402c888741f79216ea5008f68a2c5cb
MD5 e6ef83ff9db322ac474a12816659cf11
BLAKE2b-256 c72768d2a92e7c78e3d4c38c2c8d54720e44a7f7cded040e0bbff25f6dd979d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 756.8 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.5

File hashes

Hashes for arch-4.19-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 5065c302a66dcb461f8b2af6209808a74eb073aa2166b37a52f89c230b35ef69
MD5 7cf5ad5912bb7f67e6dda620c3e87ec6
BLAKE2b-256 778155245438805a928fd5ff423845529362145a9b3a52154c3293f89c9c212f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 807.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for arch-4.19-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9437da1540c8d442a6a38079906cd46b451c9f95b9e02a61c9ce3dccfa4feb29
MD5 b18dfd00fd2c31e766122bea8e17b557
BLAKE2b-256 5fa8a85dad77039d2884547d4fb83d54edfc13a12e31981934d6d0fb6303b791

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 795.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for arch-4.19-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 46c059fe4e8d43e4c8a1e3d73cc5785d945b18d0f2f26e2a684c7d8ed2412a4f
MD5 0c1f6bef0b109753927d5c136da32bfd
BLAKE2b-256 4b7c01a7cba8be6128600de575352bb9b72ba0acdfc781ab13339c5e2a78e785

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.19-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 797.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for arch-4.19-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5f4a8dd8cb2bb127683cf9700fb71c543fd2522a2cef8f741aca6a505a7f34ac
MD5 bc36562f0aa6ec717376412b5d71194e
BLAKE2b-256 4f87b5d0e6521622462f3990c179c1eae7a0d02588f0cf2f0147ad35ebf3afd5

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