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.11.tar.gz
.
File metadata
- Download URL: arch-4.11.tar.gz
- Upload date:
- Size: 789.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3d5cd9086e7c44638286fbe46a4688a3668ab79400a1712c3ce43490be0c3bb |
|
MD5 | c0e70ee0fc5dfb6aea38a8d4ee4791af |
|
BLAKE2b-256 | 3428807731d5fd2512ec79401fbbaa84d9dcb76edbeb8ce36a5717375d6ee452 |
File details
Details for the file arch-4.11-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: arch-4.11-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 684.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.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2b8618c6596d059fa64fba51fa4a2f47ab0746bf8e8122a7f737f1e1bb7553c |
|
MD5 | 05974a97d40884d71e881d56dd5dfdbe |
|
BLAKE2b-256 | 39030aceb440972f7b06c8279b30f8873db68b4e5d75c84dfd0037b94a7e6257 |
File details
Details for the file arch-4.11-cp38-cp38-win32.whl
.
File metadata
- Download URL: arch-4.11-cp38-cp38-win32.whl
- Upload date:
- Size: 656.0 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.41.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2d77ce9c20e1c75f7ff481ff8e277e3afa01885a52abe158e7041ff471e381 |
|
MD5 | 6b5a9d2f9cefa60cfad403b2226f1dc6 |
|
BLAKE2b-256 | 9d64ddf82d95cb7d67ec75101409b1057bc6dd76fb7bcf79d19f70b76f1b734f |
File details
Details for the file arch-4.11-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.11-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 709.4 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b3b510946ec28654787e0a2523c284c6d940fd7e3bb161d2c586dd07a48065 |
|
MD5 | a099d3f0df391fed6111bcdcb2de0273 |
|
BLAKE2b-256 | 9f71e3e87c9aab0437f33703ed6fd10dcdba16ba823e7a303e5dd1bd58b0dfac |
File details
Details for the file arch-4.11-cp38-cp38-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.11-cp38-cp38-manylinux1_i686.whl
- Upload date:
- Size: 685.7 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d9bd1651a23f6858214c9e68b08ab3ef8cc215196622321c07605e05f9419bc |
|
MD5 | 4b3a6f88ecceac121873cd99e5f9b5f4 |
|
BLAKE2b-256 | 0b02c69f0b5bbfc960f26085a655c444976bc7502de9c585f009b81693259e23 |
File details
Details for the file arch-4.11-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: arch-4.11-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 694.8 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6c1c4ecbf601cf2475bc0e053846c8ef25086db6fc99d078c8d57f0928b0bab |
|
MD5 | 018d51a904d9d5a90e00b64bd926962a |
|
BLAKE2b-256 | 25c8757f7b08c0983adee74ed81d9e2214d50711e7f6a648c128600e294d0a92 |
File details
Details for the file arch-4.11-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: arch-4.11-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 681.0 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1ad4689f4134e3402f87a91fa8d5db06b48805d4920500ffcb340f375b03191 |
|
MD5 | 0818ed677d4b0ac5b74369f40e2281da |
|
BLAKE2b-256 | 717c533888af6c22f1e76a7aa7bc7f1732ce11ba6200a3996412dfcb2a192779 |
File details
Details for the file arch-4.11-cp37-cp37m-win32.whl
.
File metadata
- Download URL: arch-4.11-cp37-cp37m-win32.whl
- Upload date:
- Size: 652.8 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cef2ba6a17b3228590d3af216f259863d83f9573d0ac59fad0e20ee35815e943 |
|
MD5 | 23492b34bb84fa31660cd65d24c63970 |
|
BLAKE2b-256 | a4b59fba3dd4335e25c401fc5f9388a73d8e5da2b031c3c52df03e3dae8cb210 |
File details
Details for the file arch-4.11-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.11-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 712.0 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 236e70b0021dfdc538b9b636fef1c2a5e4d370877f5af2bb318fe1a6bfd01596 |
|
MD5 | 3d211dbabd339bb87b0340601d0d1837 |
|
BLAKE2b-256 | cc63b389a75d1612c4b17511debad78dc4f2bad0cd47890b50c185611c486056 |
File details
Details for the file arch-4.11-cp37-cp37m-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.11-cp37-cp37m-manylinux1_i686.whl
- Upload date:
- Size: 687.7 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d74dd0cddb0e5ce6fb9a64e64c6b323ff4ed86bd4907099666aec39f1646f20 |
|
MD5 | 492ffae43c96c84b7acd2273abfa90e4 |
|
BLAKE2b-256 | 8484c1f175bddba85333db7a7ae4a2df526b4b6f599f3269a1bc256b37b6771b |
File details
Details for the file arch-4.11-cp37-cp37m-macosx_10_6_intel.whl
.
File metadata
- Download URL: arch-4.11-cp37-cp37m-macosx_10_6_intel.whl
- Upload date:
- Size: 850.7 kB
- Tags: CPython 3.7m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cd9ae94ccffa0015a39ae61ee0282cbc4fabfe786ab78d918efdcd9adbca45d |
|
MD5 | 63e402ffd2d2cd1fea3b18bdb4e4631c |
|
BLAKE2b-256 | 19fbc0dbb474070358054e99578116c435d0e24958facee74a4bb9cdd38caa9f |
File details
Details for the file arch-4.11-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: arch-4.11-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 681.0 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a74cf63068dfa7bf2fc18528bb532b36e82e4f6b36cc586ea303ae6e1aaa71 |
|
MD5 | 583deb25ff277193189c483c8f5a4111 |
|
BLAKE2b-256 | 0fea6d07c26f5ee522f6777557d3d3e9a55e52642b667edd1fd5cfadfee3c1c4 |
File details
Details for the file arch-4.11-cp36-cp36m-win32.whl
.
File metadata
- Download URL: arch-4.11-cp36-cp36m-win32.whl
- Upload date:
- Size: 652.7 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad0627d4f9441b2b76bbc88cf66305bc46ce69fc372436302395f8cc752a2c78 |
|
MD5 | 79204ca453133f866ac89a5ec7d1bdc6 |
|
BLAKE2b-256 | 4cf9a9b399f5bd386a66d4d7c5a1a69ef0c1027bbccdd44bd82d6d96b7b58ee6 |
File details
Details for the file arch-4.11-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.11-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 711.9 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdc2073d4a003f707ffade64c4686eff413b5d636041ff6f54270d5ee4cc7356 |
|
MD5 | 81f77be1450adaae2a1e21221c384ae0 |
|
BLAKE2b-256 | f59e7628ae53df0494a08d256dcdccc2519aa058c7c7ccb0fc6ca4a380b0bc86 |
File details
Details for the file arch-4.11-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.11-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 687.3 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7c1289b4c6bbcda371737055d14fce8f495446b53fec22609144290b3c2fbf8 |
|
MD5 | 0e0c469229367c9988d2a54f1e3657a3 |
|
BLAKE2b-256 | ca23fbc07c342abcc070dca40bc5d190662b102096628564b1bbf70398393629 |
File details
Details for the file arch-4.11-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: arch-4.11-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 695.4 kB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27d7018e660e6c7fd11bff8e7dbe50871beea62e17ec88563022b3f5b3fc00ba |
|
MD5 | 227742861076180fe57c9d7ed618a9f1 |
|
BLAKE2b-256 | ac7329a237fb30c9eda3fbf32794dfad64dd5c34ded811dfc3489fee20744f73 |
File details
Details for the file arch-4.11-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: arch-4.11-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 679.5 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.38.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a218a18d0952c1a8696ee7022a2d428a8c2474f3c42ff4a8daefec881742e18b |
|
MD5 | 74daa626d7455bc0644855d6cd5ceeb3 |
|
BLAKE2b-256 | b945ef4eee1dca641e2e056fa0478263037122ae766ef82dd0accb6fe191f726 |
File details
Details for the file arch-4.11-cp35-cp35m-win32.whl
.
File metadata
- Download URL: arch-4.11-cp35-cp35m-win32.whl
- Upload date:
- Size: 651.3 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.38.0 CPython/3.5.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bbd8abf5cda7246126482a8410b62fd30d6a545a4f3c1a3e8126222c5c2a7e |
|
MD5 | bacd3af42cecbb7b3bbfa6f11ece61db |
|
BLAKE2b-256 | 026bfcf9e379e6690056a3f855cf581a06da852b3d091fa1d9282b8864933227 |
File details
Details for the file arch-4.11-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: arch-4.11-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 709.9 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9172d13552c5a856f12772863936430aae2b14bf90e96e8dab03eaf0508bfe74 |
|
MD5 | 37fd3aaac4db2eb44d7999ca58229a45 |
|
BLAKE2b-256 | 3cb7e8bcd0ad64a537203cd05d5784144ad58361ecac09f983de8beecfb2e1d7 |
File details
Details for the file arch-4.11-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: arch-4.11-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 686.1 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0393c047f59edc2def62192ab631ce3b8a981804ad0cfd67c3761b789167d158 |
|
MD5 | 46b4a7b5a50b49b0f539c3a15a116804 |
|
BLAKE2b-256 | 1756b2686f763c5e8ab5790b3bfd9adeef2e999c12bd490ea5fd8da41bdcac2b |
File details
Details for the file arch-4.11-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: arch-4.11-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 691.8 kB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb58ad11d86e5838948a0ae72645d06574fe88971f0bd445e592b63fd84540ed |
|
MD5 | fc3dc4a877ba9be72f0e1f866ba7fcf4 |
|
BLAKE2b-256 | 97f06e78d0dc18c7355c7ac0142ba79bdf2e172d8298db281d4d7cf38940f02f |