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.

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.

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"

You can alternatively install the latest version from GitHub

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

--install-option="--no-binary" 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.13.tar.gz (795.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.13-cp38-cp38-win_amd64.whl (693.4 kB view details)

Uploaded CPython 3.8Windows x86-64

arch-4.13-cp38-cp38-win32.whl (664.5 kB view details)

Uploaded CPython 3.8Windows x86

arch-4.13-cp38-cp38-manylinux1_x86_64.whl (717.9 kB view details)

Uploaded CPython 3.8

arch-4.13-cp38-cp38-manylinux1_i686.whl (694.2 kB view details)

Uploaded CPython 3.8

arch-4.13-cp38-cp38-macosx_10_9_x86_64.whl (703.3 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

arch-4.13-cp37-cp37m-win_amd64.whl (689.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

arch-4.13-cp37-cp37m-win32.whl (661.3 kB view details)

Uploaded CPython 3.7mWindows x86

arch-4.13-cp37-cp37m-manylinux1_x86_64.whl (720.1 kB view details)

Uploaded CPython 3.7m

arch-4.13-cp37-cp37m-manylinux1_i686.whl (696.2 kB view details)

Uploaded CPython 3.7m

arch-4.13-cp37-cp37m-macosx_10_9_x86_64.whl (701.1 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

arch-4.13-cp36-cp36m-win_amd64.whl (689.5 kB view details)

Uploaded CPython 3.6mWindows x86-64

arch-4.13-cp36-cp36m-win32.whl (661.2 kB view details)

Uploaded CPython 3.6mWindows x86

arch-4.13-cp36-cp36m-manylinux1_x86_64.whl (720.4 kB view details)

Uploaded CPython 3.6m

arch-4.13-cp36-cp36m-manylinux1_i686.whl (696.6 kB view details)

Uploaded CPython 3.6m

arch-4.13-cp36-cp36m-macosx_10_9_x86_64.whl (700.6 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: arch-4.13.tar.gz
  • Upload date:
  • Size: 795.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6

File hashes

Hashes for arch-4.13.tar.gz
Algorithm Hash digest
SHA256 062b8541ee4043410db1e3fce9720e414505edff3d49a784179957726cd7b25d
MD5 6d4ebfc3087b69965f1d7add75536a65
BLAKE2b-256 a3427de0b6ea37b747ef0cd9d1bc1e5464f87d9c33011141a08292babd0b3093

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 693.4 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for arch-4.13-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5518eee58b581c1980fa553dd0a63ac8c57988f6686d245bbcd228b2234bdb7f
MD5 981033381bd213805d1c07d418416fcd
BLAKE2b-256 a220b199a790498273dd0b4e8ed67621f82deaed1a22b64d7dd2a14e19f9e065

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp38-cp38-win32.whl
  • Upload date:
  • Size: 664.5 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for arch-4.13-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 bcdc0f0657d63240f02879a83325a3a0184f375f8baee4ea2303980e435cfa49
MD5 097972c4c93f3b8e6abfa0e5cf05a339
BLAKE2b-256 2af3f974040da5b721494e44b159dde95b1dcfea794079d1b078363187db0d82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 717.9 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for arch-4.13-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c7622e5c6a6d6a587b290200371e0341c4480533afa1aca676ae57d083894af2
MD5 b80affdc793178d794c473745228085d
BLAKE2b-256 7f17a97835458d4e31fdca6f24655991d6441ce116640cc5b208863d8ac23e3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 694.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for arch-4.13-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1fe34c634cc9f2ed1cae0cc5d960028f0d6c87d06b7c6328970abafbb45e9153
MD5 3a29c5a3c87efe1ef4f09811c03a8fb8
BLAKE2b-256 4e2f2d983f18bd876f9111b3bde8bbce1fe9b7233738e4b449957b31a8baa402

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 703.3 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.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for arch-4.13-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7cba76445671f18ed651a7ab836066015a720bac851c94aec29303425aba855b
MD5 5eca95ea086501a789fa3b0cf6ad8c12
BLAKE2b-256 d60487e415360300a2faa864dac80fc03e98636f630956bb38c6c69d4c7ffe11

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 689.5 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for arch-4.13-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f86cfcc343252ab5eabc74361cfa1ebb435397cb0d4ac11727e1d921d2e988b4
MD5 966b528ae94b1ac147cfd26f56922221
BLAKE2b-256 0b9d5c8e999d60178a0f142c976661d981de01eafc47746a689aaf353b9c7933

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 661.3 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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for arch-4.13-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 b0fc9f0838503eedc14b8a924c280f7b90022f5247ba76c5b8f7e33885ec9ea4
MD5 da57a405798e3a491adf089c4d7d7a66
BLAKE2b-256 c5e3ce9506c120d7c2507409e13d22678128dc51e808763df732fc3367f4a0ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 720.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for arch-4.13-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ab37122760d1925353c52e5d2816fc4824bed827330a19efa0303b94e3c28bff
MD5 74fd8ef487b614a67d04d6965499eb22
BLAKE2b-256 1d0ee7a4aaa61312125c57268ea924ad5c8b7a8f9288f0133d5c2d60bb0eaf20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 696.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for arch-4.13-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 73434562c1eb4d746cbde0fef9a27fd7a38bdcc67352f8e28ed44af9f0fb7931
MD5 9c6a85ce61e1f4963492e3003575f5e1
BLAKE2b-256 496fe64702ca15e2eb07e4e3139f13b4cfa503b89e4d92453059db2fd69510b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 701.1 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.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for arch-4.13-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3119c897a284526530e3d276e38ccfe88c61e038510d8e48dfec8b74bdc86375
MD5 226e69e5208b7a8fd63c47e89f54165a
BLAKE2b-256 b3e3abaf82ed3d5e87fdbbe97ddc80fbf8ac20c3c5820a1fcd21d41c629dc945

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 689.5 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for arch-4.13-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c8dc18d682f9cc6f2b2dd0d30e7b7f17a9348fd69ac975832664ff5463d6f5cd
MD5 bd06f5990afec55f7667d039136bc8e5
BLAKE2b-256 11fdd468ad4564ce46ead18e1bea869dcf5b31989e398f0c4ffa98639500cc67

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 661.2 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.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for arch-4.13-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 0d072d1c8215ddec48fb835e9705f65e0ff9598efa69338674da3b93869b99e7
MD5 acb19b0420cdea3251b5d1039a4e2684
BLAKE2b-256 b85ca9be38f4c675bdbebd6932267e9b8520bd1d375b9d016b86cf263e51bc99

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 720.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for arch-4.13-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a22241d03ff5ce43fa7162347f11f29c8f81bd85027089985c2f53b599f7c101
MD5 9a8a5702d24061d69a899f05301be624
BLAKE2b-256 e78c75fa4d36a8cb85dd20b4ca08f742e357c3f2a3fce499da31ed37f4b1622f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 696.6 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9

File hashes

Hashes for arch-4.13-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 a84fe394b26c444eaed66d49b35e6a00959864dcbc6dc02cacb48f6b98d26028
MD5 c47b9fc5da0046edfc3d15a181dd9866
BLAKE2b-256 c9a5dc7620907b7a4f81a1590ff5aa4992d307605098b77084a716818f60f7ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.13-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 700.6 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.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for arch-4.13-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 26e44a2730726102ce19242daab034b678fd46b3566445bace80f77ce7a32ca3
MD5 12b0c03d7790d2e0dac148500b0b527d
BLAKE2b-256 d212836191ee270047df2fe254f7fbde91b8534ba4871ed1deec8b43263190cd

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