ARCH for Python
Project description
arch
Autoregressive Conditional Heteroskedasticity (ARCH) and other tools for financial econometrics, written in Python (with Cython and/or Numba used to improve performance)
Continuous Integration
Documentation
Coverage
Code Inspections
Citation
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:
If Cython is not installed, the package will be installed as-if --no-binary was used.
Setup does not verify these requirements. Please ensure these are installed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file arch-4.10.0.tar.gz
.
File metadata
- Download URL: arch-4.10.0.tar.gz
- Upload date:
- Size: 788.5 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0682d4953d36f2326a666f55420ec19337a885b427e1b6fb89546a49b8c8ac90 |
|
MD5 | 187cf675e037069ed984158f2398e3af |
|
BLAKE2b-256 | c8ea914559a5d177c953a53dbec16ee60f7c2a76b0ccb0de7f4dfbc7f58e128e |
File details
Details for the file arch-4.10.0-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: arch-4.10.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 680.6 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 097ba9bfbbc7ba50d49c2af279d860d7500cad5e72e91651746a808ba01ad025 |
|
MD5 | de9391ee36dba401df3da80c6c92f259 |
|
BLAKE2b-256 | 96dfd160976714189ede3d158933f518dcae255493d8f1c22f3e26e21d7c8d49 |
File details
Details for the file arch-4.10.0-cp37-cp37m-win32.whl
.
File metadata
- Download URL: arch-4.10.0-cp37-cp37m-win32.whl
- Upload date:
- Size: 652.2 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a09d5da56610b6539ceea45587686af4cdd9bb47fe8c4fcfe076875c66420488 |
|
MD5 | 8d853e95c6b9c5ab90e181c0f50ddbbe |
|
BLAKE2b-256 | dce86f6bd947d75f67754208380ed58209729837d579369e22566e43f7466898 |
File details
Details for the file arch-4.10.0-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.10.0-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 710.1 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa4fd6bb4711882ee9d0b66572e2287f36584b3ee2401db71e9a71a1070e09a3 |
|
MD5 | 20135e44611eb89b85b862fd1161a301 |
|
BLAKE2b-256 | 3e67372844f460aa79e7a223c819fc00a8a7efb002c062393d577e077be092c5 |
File details
Details for the file arch-4.10.0-cp37-cp37m-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.10.0-cp37-cp37m-manylinux1_i686.whl
- Upload date:
- Size: 686.5 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87e6449fa893399b2612afd4de5107ce182d1e40c8357568c1942d6a05752a8b |
|
MD5 | e9c37bb09b41af36e1ec95db311e66af |
|
BLAKE2b-256 | 4530940d6667bf50ed048581896068324baed98f14eaec727e6e8a45d3947779 |
File details
Details for the file arch-4.10.0-cp37-cp37m-macosx_10_6_intel.whl
.
File metadata
- Download URL: arch-4.10.0-cp37-cp37m-macosx_10_6_intel.whl
- Upload date:
- Size: 850.1 kB
- Tags: CPython 3.7m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc4ce1beb5151115c9fda28670cdb44e938962f813519476b2f4ff8c6c39a4fc |
|
MD5 | d572a47ae2e15affa6d24735a62204fe |
|
BLAKE2b-256 | de772c37baf97fe7dcea63b82aaa2951035dfebffdada33800ccec2e7a2cd706 |
File details
Details for the file arch-4.10.0-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: arch-4.10.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 680.5 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa4ef63229ea1c0f43e3964039666bab2311b1bf624728cfa9bd0b47726416e2 |
|
MD5 | 5bca4ae983c8a0a0cfad03e647600ba3 |
|
BLAKE2b-256 | f22f7d2abaf08baa6a70505b665878122d8be912684879ade44f74f6ed934407 |
File details
Details for the file arch-4.10.0-cp36-cp36m-win32.whl
.
File metadata
- Download URL: arch-4.10.0-cp36-cp36m-win32.whl
- Upload date:
- Size: 652.1 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459debb96b79f7d43671758916f7bc3528b3597b4bec22300b3b69c95899e2a9 |
|
MD5 | 5d0c3ce58943ffbaf0ff1a133fe45a50 |
|
BLAKE2b-256 | d096d21f781119b532fcabad8b05a9f2d530b76f1a04a46eaf513a202f812491 |
File details
Details for the file arch-4.10.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.10.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 710.3 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23d4089ebb1caf3d0bab0d0fa6c2e7c70f991998828ebf3d76de688c67f567fa |
|
MD5 | f3f8c7c546cbaf4372a9a904c7f6ab9f |
|
BLAKE2b-256 | b705241c4238e9ee8cfb78b2053c059fb5ce6d1bc32a1266eb99a39e96a00069 |
File details
Details for the file arch-4.10.0-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.10.0-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 687.4 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57d54b6d0ca8ca08fc1468b7ef80bac49c9b634e757c518f2b1e4788795f924e |
|
MD5 | 4be10398f77eed44b00e178e507dae13 |
|
BLAKE2b-256 | 25abeb5ef7eafa617d76446f2fd477ba7f09071ea139b67bb0aecea2468ce807 |
File details
Details for the file arch-4.10.0-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: arch-4.10.0-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 694.7 kB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ae26fa75a814b8130583e2da784daeb32f56e8c084e98cb861cf3c4650e5586 |
|
MD5 | 3e279ffaf7e9ebfd5a26b81d48847167 |
|
BLAKE2b-256 | ede73f22a29ef5fa6e426efd48986fef295f4c265cf0eff714ef8715063f62ee |
File details
Details for the file arch-4.10.0-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: arch-4.10.0-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 679.0 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7f04305d894be7963c648683e4d7c4b34ff3615f89f5a4ecf6610f245cab83f |
|
MD5 | 8e3fdd9ac7b6acfcbb481c56874cd00b |
|
BLAKE2b-256 | 2e7f2bb4ff24d9a1eb0061f43f44ac25fbb33bae26d52dbcdbd2b7acdd4c6489 |
File details
Details for the file arch-4.10.0-cp35-cp35m-win32.whl
.
File metadata
- Download URL: arch-4.10.0-cp35-cp35m-win32.whl
- Upload date:
- Size: 650.7 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7026938afe3a79341ef2d57ac0067e18fb9a67704d2d6f89b76a66f0241b021a |
|
MD5 | 3c1880aa54f17fcfe85fbaae3ad33c39 |
|
BLAKE2b-256 | 93dbc272e8dc793a3f6271aebf67d88ed31e516fc49b5780de3a6d2816cb5d18 |
File details
Details for the file arch-4.10.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.10.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 708.3 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7974760b03d217e72f8bbd2e485823dfa31ae8072ae307da3760d402e96a2018 |
|
MD5 | a14924d66e86b66b2c6bd85f8964172a |
|
BLAKE2b-256 | edd936c16288668d1e07b5d344a0e8f11d827b4f77c9e1ac43fb108e177a2e60 |
File details
Details for the file arch-4.10.0-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.10.0-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 685.7 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 382effaddcdf038d001eae0970f026df1d73e5a4975288b3260b5ef0b6dd4065 |
|
MD5 | 60158d38493598cd30352823631ffb1a |
|
BLAKE2b-256 | 2215c54853232f3edb1b209104a64d8190e32b50040e6740f94edff15cc2334b |
File details
Details for the file arch-4.10.0-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: arch-4.10.0-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 691.1 kB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae42c868a840a4b9ff05ab13c59b32985bc76fd45544b3d2c7ef8e307a349b8d |
|
MD5 | 720bb510f318d5fd4f257d51612d8177 |
|
BLAKE2b-256 | 8ca5c3d0a240dc1aa981cd229a89d6b1ded34defdf1b19619e9b31c2e99fa876 |