Skip to main content

ARCH for Python

Project description

Autoregressive Conditional Heteroskedasticity (ARCH) and other tools for financial econometrics, written in Python (with Cython and/or Numba used to improve performance)

Continuous Integration

Travis Build Status Appveyor Build Status

Documentation

Documentation Status

Coverage

Coverage Status codecov

Code Inspections

Code Quality: Python Total Alerts Codacy Badge codebeat badge

Citation

DOI

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.io.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 pandas.io.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.5+)

  • NumPy (1.13+)

  • SciPy (0.19+)

  • Pandas (0.21+)

  • statsmodels (0.8+)

  • matplotlib (2.0+), optional

  • cached-property (1.5.1+), 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.5+. 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.24+, if not using –no-binary)

  • py.test (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.9.0.tar.gz (788.1 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.9.0-cp37-cp37m-win_amd64.whl (679.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

arch-4.9.0-cp37-cp37m-win32.whl (650.9 kB view details)

Uploaded CPython 3.7mWindows x86

arch-4.9.0-cp37-cp37m-manylinux1_x86_64.whl (708.6 kB view details)

Uploaded CPython 3.7m

arch-4.9.0-cp37-cp37m-manylinux1_i686.whl (685.2 kB view details)

Uploaded CPython 3.7m

arch-4.9.0-cp36-cp36m-win_amd64.whl (679.1 kB view details)

Uploaded CPython 3.6mWindows x86-64

arch-4.9.0-cp36-cp36m-win32.whl (650.9 kB view details)

Uploaded CPython 3.6mWindows x86

arch-4.9.0-cp36-cp36m-manylinux1_x86_64.whl (708.4 kB view details)

Uploaded CPython 3.6m

arch-4.9.0-cp36-cp36m-manylinux1_i686.whl (685.4 kB view details)

Uploaded CPython 3.6m

arch-4.9.0-cp35-cp35m-manylinux1_x86_64.whl (706.5 kB view details)

Uploaded CPython 3.5m

arch-4.9.0-cp35-cp35m-manylinux1_i686.whl (684.8 kB view details)

Uploaded CPython 3.5m

File details

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

File metadata

  • Download URL: arch-4.9.0.tar.gz
  • Upload date:
  • Size: 788.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4

File hashes

Hashes for arch-4.9.0.tar.gz
Algorithm Hash digest
SHA256 e60b7ba8e7b9da35dc4e99b4ab359ead28c760e31a93b8c222d670b187174a15
MD5 b1c1c7f4ed304baf3728efba0cd56487
BLAKE2b-256 0e72e10e264e35b692f9bae2e772fa11c6f033010b64f10911b924cd28a1378e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 679.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for arch-4.9.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 86b8997aadfa30548c975b3a6e0cc9df345a6971f74eb31d9cb5fb30326b36ff
MD5 759c52b0060003d31265b772c6e88412
BLAKE2b-256 a30bf0af26a986bf5513d5343754d3a10f5dbe65e0d1239478d2c841819f9823

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 650.9 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for arch-4.9.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 fb8f548bbd0efd34ebcc49f3aa8557296641e8f7a6e81e7877d0c8ef9f853e51
MD5 1598d521937a7c461f1e319bcd238730
BLAKE2b-256 895acf62f08ffc1b8ff8a104241be258ea821ffb7068269e3bbd2132605fd9fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 708.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for arch-4.9.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0b4e5b4d8857345cfbf5b986dfb157c76f6d1dea42cc7c13bee72aced471429e
MD5 88a0f0a62ed1c3692ee9b48c460351c4
BLAKE2b-256 db4801059a9542cf33ac752345661f714b15ecc711103bde8fea7e2fa9b33e9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 685.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for arch-4.9.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 08b92f37784157e1fd855cb0512caa6bc0b233de6ddb29a3483ef0f0295c6365
MD5 e2743228b266ab0902c40f83dba2b3c2
BLAKE2b-256 0e3e1382e91074e4adc8ce4ed8a771d487d0b5d7fead9089e55d243f6c4f2f3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 679.1 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

File hashes

Hashes for arch-4.9.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 54cc61e81705662069978a60c2102f78df517c622bc0de55100178dc7d20c7eb
MD5 93d212159cea7da5c7ff839c5011b3da
BLAKE2b-256 5c0040ddd1940e320a7fe853e49e6992a810aca4f18cc5bb7faba1abc2f58aef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 650.9 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9

File hashes

Hashes for arch-4.9.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 a4915d3210e075f6e9294b90c036c039562910d559b8265fd425c21a07997b09
MD5 0ccde67f57efd6afaf2cdf88d456dff1
BLAKE2b-256 a54aa962c3a2d2d8f71b3411098a64990bc01ef5e6a04bb6e8dfbfc92dc9d4a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 708.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for arch-4.9.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 57a9de4cd607a1712efeea358ac553dadf523e13a1c917fde299ffd528eb1803
MD5 cb35c07b3e1c830d9e0f3c74da48a262
BLAKE2b-256 92629117499079f2eb57f1333ac584e8667945119b9b79db5aba066a9c538071

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arch-4.9.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 685.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for arch-4.9.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0c134e8d0cc9e8bff3edabe1d435775255d9193de118b9a888006213ab39bcf5
MD5 2f684ac71fefe2fcdfad4d16d6189eb6
BLAKE2b-256 fc172317f68e1d06bdd4a2a25a876ad75026f5e98553d62d52b61090b8a362aa

See more details on using hashes here.

File details

Details for the file arch-4.9.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: arch-4.9.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 706.5 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for arch-4.9.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 aca699e02906dc7abd525aa784bcc259757348baf1461f0dac640c211e24365b
MD5 b85f3c794db177c51dafa1cb39f0775e
BLAKE2b-256 2667fa580ef2c263b36e84a37459ae3be24bb64002c5fe226ede5d5e097b1b44

See more details on using hashes here.

File details

Details for the file arch-4.9.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: arch-4.9.0-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 684.8 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for arch-4.9.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 db341fa73ed899b6587303941832feff62e4e48d79a4c1bb2708055248059ced
MD5 ca06d50a16ee56855113f1c028e14415
BLAKE2b-256 f49ce6a7325a6e3e81aa199faa65c0c3185b1271b4a9799060d886eece1adb99

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