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 Travis 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.6+)
  • NumPy (1.14+)
  • SciPy (1.0.1+)
  • Pandas (0.23+)
  • statsmodels (0.9+)
  • matplotlib (2.0+), optional
  • property-cached (1.6.3+), 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.15.tar.gz (872.4 kB view details)

Uploaded Source

Built Distributions

arch-4.15-cp38-cp38-win_amd64.whl (769.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

arch-4.15-cp38-cp38-win32.whl (744.7 kB view details)

Uploaded CPython 3.8 Windows x86

arch-4.15-cp38-cp38-manylinux1_x86_64.whl (787.2 kB view details)

Uploaded CPython 3.8

arch-4.15-cp38-cp38-manylinux1_i686.whl (776.6 kB view details)

Uploaded CPython 3.8

arch-4.15-cp38-cp38-macosx_10_9_x86_64.whl (782.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

arch-4.15-cp37-cp37m-win_amd64.whl (766.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

arch-4.15-cp37-cp37m-win32.whl (741.1 kB view details)

Uploaded CPython 3.7m Windows x86

arch-4.15-cp37-cp37m-manylinux1_x86_64.whl (790.2 kB view details)

Uploaded CPython 3.7m

arch-4.15-cp37-cp37m-manylinux1_i686.whl (779.2 kB view details)

Uploaded CPython 3.7m

arch-4.15-cp37-cp37m-macosx_10_9_x86_64.whl (783.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

arch-4.15-cp36-cp36m-win_amd64.whl (766.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

arch-4.15-cp36-cp36m-win32.whl (741.0 kB view details)

Uploaded CPython 3.6m Windows x86

arch-4.15-cp36-cp36m-manylinux1_x86_64.whl (790.2 kB view details)

Uploaded CPython 3.6m

arch-4.15-cp36-cp36m-manylinux1_i686.whl (779.0 kB view details)

Uploaded CPython 3.6m

arch-4.15-cp36-cp36m-macosx_10_9_x86_64.whl (782.5 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: arch-4.15.tar.gz
  • Upload date:
  • Size: 872.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1.post20200604 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for arch-4.15.tar.gz
Algorithm Hash digest
SHA256 8a3f80fe300f8f0cbf7bcdb337dbd3666d7371984bf91bb47fa8ffda6b0e1449
MD5 72e996b3b2d4e5ffc7f091c0ef4df8f9
BLAKE2b-256 7edf369bcb1aa67a2b9ecaeb3b010a6fa8e71614651a7db13cc4fb9f7491f6a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 769.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0

File hashes

Hashes for arch-4.15-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ded794b9856aaa16a834ac5aa819d8f514c3909a49f695e2ffdaa6f76fe94b40
MD5 88b5c4605171adbfa8ada531d5f65b41
BLAKE2b-256 f631d9eeebdc4c76e46e732b2e9dea09ddff2b068a3b2b3ae11ca6d807227534

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp38-cp38-win32.whl
  • Upload date:
  • Size: 744.7 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0

File hashes

Hashes for arch-4.15-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 e5958a05be1a52687c42b0054ca8e93ebcc8a540fefab38abd54b8aab170bd45
MD5 992cb274fdd1e9aa6e7ee0ba3108818a
BLAKE2b-256 8b743330d1f307b5c5230e40079faee59ee1b80c847b424b657854ac9dbfbd54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 787.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for arch-4.15-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 808835c25f23ef3794316b7979f17764ed5c511c3034e0fe30f3ffffcb0cae10
MD5 2b7007f47e9eca29c1c500b9328d6aa9
BLAKE2b-256 3b35bf30ea753f32b1e442ba8d45af1ae1c7b59bb5e0488752e49189b5f37693

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 776.6 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for arch-4.15-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 30fb325505fb7de75a85ba238b5717dc8aeeca9660ae554b82f17dcfb9c007d7
MD5 d953b784c4b91f882a763cd74ada85d6
BLAKE2b-256 d690199dfe6eba6a232001f9b5dc2249ba584efbd05698f2a86769d31dd6dc75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 782.8 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.8

File hashes

Hashes for arch-4.15-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7ea0fb68085f724995127129df58fc4fd9df7346e88b37662ea70baff0af9c52
MD5 7a35864c69df56df95260f772ef93241
BLAKE2b-256 5d4fa41299a51c64cf3b8757c87959c52deee814aaf9db58ccde22f657418ba5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 766.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

File hashes

Hashes for arch-4.15-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9215d5d511aa2fdb4ef5a7667e2fc2cd407c955833b3bc0b6507c7d55d2474cf
MD5 f0c92e495247daf7c9e5610551dda3a1
BLAKE2b-256 5979031836be63549be6bd166a29b85b9b24a46500a213af570ced5940378485

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 741.1 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

File hashes

Hashes for arch-4.15-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 b7027af271c7cd41a91423a3f2d4cfb8029ebb2f3565e830c6930cfee70f2774
MD5 7b8b84d3e0b730d0cd4cd07e6c4fbe15
BLAKE2b-256 9e7fe848955f70296c534dda1d8f542799dbd0a085a61c6627e76c5f72076eae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 790.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for arch-4.15-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3268998f8c50ac84fccbec2d67a106ef9ef05fe68c2cc8ad8e4aa84a0786df5b
MD5 ea2d97b961ffa71f5d260adbff3749d2
BLAKE2b-256 fe63aea6e16dbc2d98ad5c48683c492c1785771062de2f9094f500ed7802038f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 779.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for arch-4.15-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4215ce8b31e2a51356d3a132420bc8bfe2e29ac520bc1548819e4f272052dd25
MD5 b39f86315851f437f6a5b166c27b3ae1
BLAKE2b-256 1f79243471aa4605a8e445d1a3c0b372c3f39a642906c720822cf88b71264001

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.15-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 783.1 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.8

File hashes

Hashes for arch-4.15-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4f1911299e1db5b252d9936a8ff62b167fa7f6ccfc8644a222ef499b03875f90
MD5 875d9b405f0ecd8c99be5bd51625a06d
BLAKE2b-256 8365be353123b2c9be3256bd1516346aac97b63f7b34431382eb3785bb91fe28

See more details on using hashes here.

File details

Details for the file arch-4.15-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: arch-4.15-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 766.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.8

File hashes

Hashes for arch-4.15-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 eaec799c616bcbfb83e86f7cc422ffdfadbd1afbc4c028a6d427624395bb768c
MD5 3be7345f007a9f679c70c0f6b3b69452
BLAKE2b-256 75cd26b7cf762aab8204074512a27085604dde34638ac49eb619d1ec55326185

See more details on using hashes here.

File details

Details for the file arch-4.15-cp36-cp36m-win32.whl.

File metadata

  • Download URL: arch-4.15-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 741.0 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.8

File hashes

Hashes for arch-4.15-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 22cf8762d2fd6597c6cfc0f8df0e6d57358cc98ebc1ac011de8ca6d5e3196c0e
MD5 8de30e4046775aa10464b259f6c941dc
BLAKE2b-256 b620855901259f5d09c47a4c6d148552410db6dde5acc06255db21c7e2bd31de

See more details on using hashes here.

File details

Details for the file arch-4.15-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: arch-4.15-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 790.2 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for arch-4.15-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 69524d45f03cc055f70f45e7e4abd16a16bc86a12cff3f5749a393ca4ae79da0
MD5 0213962c034d58fcb8f8cdc815f9936e
BLAKE2b-256 7f5cef80e96f2cdc6c2d293b7e4688888a4428963c966fbb0c749c9078e68bb6

See more details on using hashes here.

File details

Details for the file arch-4.15-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: arch-4.15-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 779.0 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.10

File hashes

Hashes for arch-4.15-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9fa340a5d440bfabc6af123c57cd542ed3ad5c5c3e758094ca0c4adfad70dd02
MD5 a0bede972c66f78aa1a210f34ff91713
BLAKE2b-256 bcc81e4d60002dd926777a6158d068d570609bef3824fd0122e15b27c0b98042

See more details on using hashes here.

File details

Details for the file arch-4.15-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: arch-4.15-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 782.5 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.8

File hashes

Hashes for arch-4.15-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8f4866d7a5e1ae2e0f3c1ee4f1bbd3b0dd6d6885c0f7dd57cb8a851573c1e66e
MD5 f09406040955444a1db07feecaad2e28
BLAKE2b-256 8f0baba83db12e4a103ec404b1278b6c3644ea808199af6f4c5482ae454747cd

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