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

Uploaded Source

Built Distributions

arch-4.18-cp39-cp39-win_amd64.whl (778.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

arch-4.18-cp39-cp39-win32.whl (752.4 kB view details)

Uploaded CPython 3.9 Windows x86

arch-4.18-cp39-cp39-manylinux1_x86_64.whl (796.3 kB view details)

Uploaded CPython 3.9

arch-4.18-cp39-cp39-manylinux1_i686.whl (785.2 kB view details)

Uploaded CPython 3.9

arch-4.18-cp39-cp39-macosx_10_9_x86_64.whl (791.8 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

arch-4.18-cp38-cp38-win_amd64.whl (779.2 kB view details)

Uploaded CPython 3.8 Windows x86-64

arch-4.18-cp38-cp38-win32.whl (753.0 kB view details)

Uploaded CPython 3.8 Windows x86

arch-4.18-cp38-cp38-manylinux1_x86_64.whl (797.5 kB view details)

Uploaded CPython 3.8

arch-4.18-cp38-cp38-manylinux1_i686.whl (785.9 kB view details)

Uploaded CPython 3.8

arch-4.18-cp38-cp38-macosx_10_9_x86_64.whl (788.8 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

arch-4.18-cp37-cp37m-win_amd64.whl (776.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

arch-4.18-cp37-cp37m-win32.whl (749.7 kB view details)

Uploaded CPython 3.7m Windows x86

arch-4.18-cp37-cp37m-manylinux1_x86_64.whl (800.1 kB view details)

Uploaded CPython 3.7m

arch-4.18-cp37-cp37m-manylinux1_i686.whl (788.6 kB view details)

Uploaded CPython 3.7m

arch-4.18-cp37-cp37m-macosx_10_9_x86_64.whl (790.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: arch-4.18.tar.gz
  • Upload date:
  • Size: 868.1 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.18.tar.gz
Algorithm Hash digest
SHA256 2cc4b68cdd5d2fe1778cd2fee285e147d73a658ad95a3f477bfe16d131631937
MD5 41e87c398c9b7e7bd77f4df0463e633e
BLAKE2b-256 6cea669c91798e6537c876e688b586de2229f6e056281b51d152d405810f5e87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 778.6 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.58.0 CPython/3.9.0

File hashes

Hashes for arch-4.18-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 820fa9a378406f88f2ea1ffda9d7bb5ff38e4c657decf1ab5748b7566d2d49cb
MD5 925dfa8fb32207216e39e00d1e0caaef
BLAKE2b-256 6fa463486a7358e87ba84c6f431eb6cbdeb338e1ab5abc4a7bc11e8af98be1f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp39-cp39-win32.whl
  • Upload date:
  • Size: 752.4 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.58.0 CPython/3.9.0

File hashes

Hashes for arch-4.18-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 a1403d1dd5b9aa7fcd8f8dc9f16a77a86e5d62dcb5a43c60b88d4b3b1a8282f9
MD5 d31a1928aa8978fc56da9d43c6696e0f
BLAKE2b-256 4de129d7e641ca44136e2bf19c9bebec76fbc964465899581f26ae6df462088e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 796.3 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.58.0 CPython/3.9.1

File hashes

Hashes for arch-4.18-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 06ee18bfe164ae76605350abe9a5800df8f6d049a243bdce77c347fdf24d0bb9
MD5 c697daf30e90974bbe7d27cb1da7110f
BLAKE2b-256 4b31687bfa8fd8cdfae5d24b6d7e53d6aa75804e5b933cde9afcf7d4d492a61f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp39-cp39-manylinux1_i686.whl
  • Upload date:
  • Size: 785.2 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.58.0 CPython/3.9.2

File hashes

Hashes for arch-4.18-cp39-cp39-manylinux1_i686.whl
Algorithm Hash digest
SHA256 f67c1c8de3aa8d9e308e18dd12b51cbc27705cd642167249223bfdbcac85ce37
MD5 3075473f6b1ce85f68ff14194d3799b5
BLAKE2b-256 bd0ca0274aa3599f351158fc3cea05e4b286413f89708b18f5d71f31bf83b583

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 791.8 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.58.0 CPython/3.9.2

File hashes

Hashes for arch-4.18-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 17ac9703af5ea1cbd61cbdde075c59bf7b2b777fd965248260ac1867ee0a0668
MD5 88fcb147777a2635c1cfd1f75fc63987
BLAKE2b-256 2ecf54f5a35f71251b6bbcee5db60813e609a308601ee98f20158ebdc38aa260

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 779.2 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.58.0 CPython/3.8.0

File hashes

Hashes for arch-4.18-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 aee6cf06e926dbc8bf8908b2902bcf7215e1f5b89425ba4a0c63a41e1b2376a7
MD5 da655b35f8409f244ab3e5c7497d0503
BLAKE2b-256 301e6e87a48322f4061868510c73cd2160dd676830f928f9283788e1c943df75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp38-cp38-win32.whl
  • Upload date:
  • Size: 753.0 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.58.0 CPython/3.8.0

File hashes

Hashes for arch-4.18-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 29edacf72bd330193ab604a6d88e1ca4ff555c1e65ee58c5c27eee8ac51a56de
MD5 05394e13ea5586d460c17b6ea9f9e6d8
BLAKE2b-256 89244035fe03fe6eb4cabdfa478ee2d04c6e6aba040e20a6b4a60b2c64fd8f8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 797.5 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.58.0 CPython/3.8.8

File hashes

Hashes for arch-4.18-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 af4ae149c4c3ee7eb9c96f25a0872c2837f70ccdd3eaf7e2c369dd5fb744dcd2
MD5 6686c6126af8f6019c6f5254eb2c6d5b
BLAKE2b-256 19b9d91ff17297c52c3c006e32fd1e25a49ca89e3e13a4c873b02b5a0fad5478

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 785.9 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.58.0 CPython/3.8.7

File hashes

Hashes for arch-4.18-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8a44e0a27e29ed01e64b45fa1b7667bff201f737db020a3bcade76a4ff1938d0
MD5 9f6391000c76fd7403407dc061e698ad
BLAKE2b-256 2248d0ff1d16124caa0065baf3282682f87efd8b09988008834f145540809d6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 788.8 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.58.0 CPython/3.8.8

File hashes

Hashes for arch-4.18-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 884b89e4e534cb554c54ce4c8ea4794594d891b721c4c40d26f2f2f94ca6f903
MD5 7b8e0dbffbb0e6afdfb88c31af4f73f4
BLAKE2b-256 789c683fafd3b2effa280281c009b40c41ace6a2bde0deb1599877c52b3c0a2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 776.2 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.58.0 CPython/3.7.5

File hashes

Hashes for arch-4.18-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 5f6d70110163d32260b1e35221ee0bc058528619209759ae4d5a0516be1634f2
MD5 7c5eb5683c0811ae74bc021ce78a919e
BLAKE2b-256 bde82788c1ac76bb21f7fe2a23ed17f286b39b31948439814f8afb557fdbe3a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 749.7 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.58.0 CPython/3.7.5

File hashes

Hashes for arch-4.18-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 2d7f6f225deb546c0270ec961f36c08e0e521f108d0160d959f9bb6312acf3b2
MD5 83104a8e4cd9560642a1bde3ef50afe4
BLAKE2b-256 eb76f001973f6b565e2ab7f87534a0753a2c71ea6c3a5d6fb8dc11f1835877cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 800.1 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.58.0 CPython/3.7.10

File hashes

Hashes for arch-4.18-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9e4b082e619467985cee0e1550fad112fe75ecae49e458cf8a1a9debbb2229a8
MD5 16d641bb5949592b2c40b0a216125fd1
BLAKE2b-256 3490fc811581ff78dc18ede58d4035875786035a5e923f84a6bedb2d3c176111

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 788.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.58.0 CPython/3.7.10

File hashes

Hashes for arch-4.18-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2213f2aebf9533a6f0b0ca7bfe9ac8f8f4e85a34a9809fcfb14ee8e703e78085
MD5 4def780b72e843327d04c8a39e77e4de
BLAKE2b-256 7915938ee0972197a127d86ffabfaab4a06d05db8154bc2ad176849bbc6b7294

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.18-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 790.0 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.58.0 CPython/3.7.10

File hashes

Hashes for arch-4.18-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 37927539b1db0b2bc3a5bc29fba290395bb73ab081d2c20ad1353a03a360b9bb
MD5 99866df92eb00eb0cc9d6b23b787a416
BLAKE2b-256 573bb9bc4800ef66927e60a7bae495a3023dbc1d430ed9677bc3bba2c523b1c5

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