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
    • Emgle-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.14.tar.gz (871.6 kB view details)

Uploaded Source

Built Distributions

arch-4.14-cp38-cp38-win_amd64.whl (778.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

arch-4.14-cp38-cp38-win32.whl (749.9 kB view details)

Uploaded CPython 3.8 Windows x86

arch-4.14-cp38-cp38-manylinux1_x86_64.whl (803.4 kB view details)

Uploaded CPython 3.8

arch-4.14-cp38-cp38-manylinux1_i686.whl (779.6 kB view details)

Uploaded CPython 3.8

arch-4.14-cp38-cp38-macosx_10_9_x86_64.whl (788.7 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

arch-4.14-cp37-cp37m-win_amd64.whl (774.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

arch-4.14-cp37-cp37m-win32.whl (746.7 kB view details)

Uploaded CPython 3.7m Windows x86

arch-4.14-cp37-cp37m-manylinux1_x86_64.whl (805.5 kB view details)

Uploaded CPython 3.7m

arch-4.14-cp37-cp37m-manylinux1_i686.whl (781.6 kB view details)

Uploaded CPython 3.7m

arch-4.14-cp37-cp37m-macosx_10_9_x86_64.whl (786.5 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

arch-4.14-cp36-cp36m-win_amd64.whl (774.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

arch-4.14-cp36-cp36m-win32.whl (746.6 kB view details)

Uploaded CPython 3.6m Windows x86

arch-4.14-cp36-cp36m-manylinux1_x86_64.whl (805.9 kB view details)

Uploaded CPython 3.6m

arch-4.14-cp36-cp36m-manylinux1_i686.whl (782.0 kB view details)

Uploaded CPython 3.6m

arch-4.14-cp36-cp36m-macosx_10_9_x86_64.whl (786.0 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: arch-4.14.tar.gz
  • Upload date:
  • Size: 871.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.7

File hashes

Hashes for arch-4.14.tar.gz
Algorithm Hash digest
SHA256 327d0b59261f47f7ebea35baf707338a5ac0e8cc6611d7033b0a66b4bae748ba
MD5 5d87a810211b12c9bd24607db2c6b42c
BLAKE2b-256 96120a550179bf9b04b61bdb7885e7dd421c3a547e6629f9a3a267bdbf8f3727

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 778.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.0

File hashes

Hashes for arch-4.14-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e2ee6d68830733d3d34af3234b9e857f43bb45b73157691f15cdee4a190f772c
MD5 1fae6a7c7d29c1fca1395f39ff355512
BLAKE2b-256 68db63a7c4c80e23a9720584a329c1cff65a1633f48e06d2c98454547c3a5e33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp38-cp38-win32.whl
  • Upload date:
  • Size: 749.9 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.0

File hashes

Hashes for arch-4.14-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 1ee72a3489eb59391b8d0c5195ab964d31dbf61fe3b489f7c49cf0bf373682fe
MD5 f59ec084ff99e58707bc11b97e551db3
BLAKE2b-256 8a2b520efdca9724a787c8e0ff87a4b76ac0785a4fdf01b4e40e0db4765eace7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 803.4 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for arch-4.14-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 38b291aa187a25a1b8e28751de9ba4b130a0455fae31143e4e6c405e04bfe56c
MD5 94111300067f9a983c6740b9ad46a4ff
BLAKE2b-256 49368b5dc4fb659d7a635a383176ec96989d6a9b734d5f514093060b826cac97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 779.6 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for arch-4.14-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 58bbbaa1a548b9d175140f960950908e5208469ec723eee6e22cad2ba281843f
MD5 67504a3f3fd9a1d02ac4178ed73ee779
BLAKE2b-256 5daa07e91f92113f9dc15a7b42e6614aaa23d071555a176824aa2b493996f8bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 788.7 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for arch-4.14-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9c9417818df36dbf12f71d8582ba5bd2db8611b2b26e8c3cc6f3d52dbb7cd6bc
MD5 1bbd18249e711d132266834b14a6cffe
BLAKE2b-256 97dffc63394e2fa147b83b4e2218e3b110ea9e663554440b41856ce5cc9828f1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for arch-4.14-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3371480eac3c1606fd71427aaa74b489ad6ec0a4330524a7ba957ab54f10fac6
MD5 ee6493f95dfa931f02568066ff7ad6d1
BLAKE2b-256 9a1e63105efbaa3b5cc51c4c0d1ea241b11827ff1b92220a701d0ee62af9c49e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for arch-4.14-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 07e5653adf8e028f023f596bde94740742054e2d6d7f5ae31beda52c8fe7a4ee
MD5 0de8e0e314a15c8e487faf365628339c
BLAKE2b-256 1164790059fcb13b3cc1153dcb4976b1fa4f07cbc69805271f0e75521e6f07ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 805.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for arch-4.14-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8637afb876250071a52e79c2a6272e3bd2f799362397f1b233d159189e987368
MD5 e0b26574ac157c1b120c210c678816b0
BLAKE2b-256 eb1cac6e4e43891285952817d8d5004d4ff67dca66db4e6be38874346f34c4b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 781.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for arch-4.14-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4ecf4e08328b4eaa0c26840a58ad0f314a08e7189e09de66f6fa88c43a1e4294
MD5 e6354a31ae7391df14c7ccb92a68a920
BLAKE2b-256 ad498420d28714b1274edc7455b7fbdffad7949377335a97c07d235edcdf1f63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 786.5 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for arch-4.14-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f272588cacfb10c47d4f7df34dbc687ddaebeacb113e5a5b6af144fd62722f9c
MD5 19b60befef4cb7f10bcf999c6b0d9035
BLAKE2b-256 b5d653985fce3a1cf9e6656ddbc65cc8e4bda0ad729b73ca6dc34094ab9c68ea

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for arch-4.14-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a04795c6c9502fe94810fa8c48dce63ef9f3df64883d8088aaaa1f913b51cee5
MD5 1c9ec86e9c5d2a50b76566077b48a589
BLAKE2b-256 901b300e1849c17645fcf0ae491e22a420a23975f0b7867febbaf44556caa1fd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for arch-4.14-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 0a451536d5e2e1e77c3fd2bfe8d55799ad5e06f57736b06ee44a6c5924d66cd0
MD5 c0184d5efea0b9019dfff53d5f4d41c4
BLAKE2b-256 432c915fa577ef2ef551c7c57dfa1aecde9cc7a5a6d0e398e7e4b903ef3cfddf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 805.9 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for arch-4.14-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0c6aa7f6d15dcd13956c05ce901294d4c0675ed197640b726a5377688c41b5a2
MD5 abad0acfd9c064223888609095843f01
BLAKE2b-256 5280d3c931ca4e432d32618315b65782c51d665e6fd078f92827421bb16517eb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 782.0 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.10

File hashes

Hashes for arch-4.14-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 81c4b7bc6e6e298a8ba55b04bafabe8dd5c2da90d14a3d2410d669e93d878c17
MD5 24351096a9428b60012fb40d9bda72ae
BLAKE2b-256 f61484d1ed6403684a0b0c57c78e0e71d75d1e8a11ce5e9bb8310733faf7acae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.14-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 786.0 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

File hashes

Hashes for arch-4.14-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e54c4287f354660ca89b8d308509ebed74150194b39aa3452d84c39dede90681
MD5 84ffcbeb4a784fde882e5610938964a8
BLAKE2b-256 8a6953d0c42f7a7d288aafd25bd3b924bebdd85fdcbb01f52d44cc14d4816a27

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