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.tar.gz (866.6 kB view details)

Uploaded Source

Built Distributions

arch-4.16-cp39-cp39-win_amd64.whl (777.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 Windows x86

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

Uploaded CPython 3.9

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

Uploaded CPython 3.9

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

arch-4.16-cp38-cp38-win_amd64.whl (778.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

arch-4.16-cp38-cp38-win32.whl (752.2 kB view details)

Uploaded CPython 3.8 Windows x86

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8 macOS 10.9+ x86-64

arch-4.16-cp37-cp37m-win_amd64.whl (775.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

arch-4.16-cp37-cp37m-win32.whl (748.8 kB view details)

Uploaded CPython 3.7m Windows x86

arch-4.16-cp37-cp37m-manylinux1_x86_64.whl (798.8 kB view details)

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: arch-4.16.tar.gz
  • Upload date:
  • Size: 866.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for arch-4.16.tar.gz
Algorithm Hash digest
SHA256 7ca8d7d9f4178f394969d4291834d7511cb0db9fcc37d6cf1d58263d672f3c86
MD5 433db0a2c2946d424fe9f82437078af3
BLAKE2b-256 bedde8486d46963f5f7fb60b25ca572736dd1afbe916e14212a98e8a3fbc1687

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 777.1 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-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3d67917ab642a82bb161bb12571ffbd328a68511e28032250e2686284d7e0bf6
MD5 34c3c8c1ecf08c9c898650f95b4056ad
BLAKE2b-256 5e6486764d6e7570f2173dd8071e6c971bc708cdc19a928c615687fad9b22e65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 f148f44827139f857f562b25e01c1a1bf68a2d75b7db9942a8229b67939667e7
MD5 8706ed1b502e51ae0f361dd6b950b48b
BLAKE2b-256 ac2a5f28151148a4252db01d2a846f8f64bb749fe2fe0edb2e64395c769187be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 869c6d039d34202c78380023d5700107ea588ff6ca70c1abd191ca19d3673265
MD5 002684196a9047c130929523d2a70221
BLAKE2b-256 33c9f232057be81869a470886e4e792f0cf40f424405e6236942e49ae30278aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp39-cp39-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6d5c2c377b831981e1d7ae5380111d2e9884e22eee1579869557034d98cce3c0
MD5 99fe9954ed4fe40e62c15cbb88534b91
BLAKE2b-256 b5c8bf746b83f92994427f2db97da3dea7605d84e3a622d37956794cfa652c8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cd2b4097a557befcb6c8b4d281f3ae0b2a0654cff02337f3bec9365cd27d6a16
MD5 6462d32eadefbe592ed885543abea1a5
BLAKE2b-256 e4b8f01464439af023a8fa13078f09291f7678a02c575ad2ffbe5a531d8d8b20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 778.3 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-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 96ef812b083c84f5fc0423524fd2432cea1e1f2a98a5bd826044ef15de1800d6
MD5 edaef38db3eb162f7018f1f617bd8037
BLAKE2b-256 9810dd78edefc9cfb8a6ad12cf4cb94db528e731e7a8c63aff73183c15f75270

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-cp38-cp38-win32.whl
  • Upload date:
  • Size: 752.2 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-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 42213d641b79fcc0f9b50f3c895cbb8d1edc70e6218ec3ca26b1cc6338ffe74e
MD5 8029ac249e0a5a68a7438e04aa2d14e6
BLAKE2b-256 6d4f818f26f1182927269f8c5a1d005f223735117160cc404dc86550b256d681

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3eae46d9e7dac44e262247abdbb38cba55925bfdaf046ee6f5775b361f626da9
MD5 bda258c3fec6905281f173a72ef7ba96
BLAKE2b-256 e7d999cb9f71a707222c09ab9d0d7b01fd785da719e9e556a071324cad52b5f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6d2bb470170b09f1fe0a7182ea5fa19396fa3a538944b1c59262a8cfb0809f43
MD5 eb97a35d00e14edb36a7818555a50323
BLAKE2b-256 7225f070a919b57449208a2e0fc3a0509c785f35c2f87b3b42c41322e306fc6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3269fca6e250b8b12a7380dba3de85c63eea3f75d141bbf191b15fdbb96af35b
MD5 1700a32594809aa5c9f0ff97e242d8c1
BLAKE2b-256 77a6e07b7eacb996f61aa8561c76c58ef92f71cdaa91a36cf7c9576a524aa808

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 775.3 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-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 305c9cb4240017b2e935b8f743eeb88424497e181b30755c55afa53b10a01d4e
MD5 2ea081265e8a09474de2716073a38997
BLAKE2b-256 e63cdc71ee80f2997882d4323fdab742180c243b4897f84e1494b42b645e238c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 748.8 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-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 c896372e78e434166e8feab138abb706a4832917982b54e8f5b8b1a9aa26f434
MD5 3ddb5f2042850651efd0be6be20f54a8
BLAKE2b-256 eab68dc51325ade9212e485e89a32d56d48ba57a5da4c549b9296b32429400fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 798.8 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-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 11c01d398be15c9b87091fad2eaddcdc7d1e8966f36e591f0d5af2d3932a27c7
MD5 6d651a4cfbd78e17928a93b1266a7984
BLAKE2b-256 fe3bb0a2375c2d4393724ab0e98ca49c46463c426307ad49d4070839830ea9fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2b3e26808a3ba2396c6ee83fa632ea7c5bc8c303aea5c25cf94ff8e4feca4894
MD5 b54fd20555ce3e06288c46e82c36e710
BLAKE2b-256 44a8eaa752ded5b384f9ebf0683f71179fd49e101571793b3b34d6b9f1fe592e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.16-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-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 70f6cca5206fc6f1a114bc50597df97208dc757309286af50da4ab4edc291591
MD5 6fb03c9f5c6d4dd89774126e91723057
BLAKE2b-256 92cfc592d80c51334c2c384c0d107a8dd160414f60ea31d94a2ba7f23fd80966

See more details on using hashes here.

Supported by

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