Skip to main content

ARCH for Python

Project description

Documentation Status CI Status Coverage Status

ARCH

This is a work-in-progress for ARCH and other tools for financial econometrics, written in Python (and Cython)

What is in this repository?

Documentation

Documentation is hosted on read the docs

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

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

  • 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

  • NumPy (1.7+)

  • SciPy (0.12+)

  • Pandas (0.14+)

  • statsmodels (0.5+)

  • matplotlib (1.3+)

Optional Requirements

  • Numba (0.15+) will be used if available and when installed using –no-binary

Installing

  • Cython (0.20+, if not using –no-binary)

  • nose (For tests)

  • sphinx (to build docs)

  • sphinx-napoleon (to build docs)

Note: Setup does not verify requirements. Please ensure these are installed.

Linux/OSX

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

Anaconda

Anaconda builds are not currently available for OSX.

conda install -c https://conda.binstar.org/bashtage arch

Windows

With a compiler

If you are comfortable compiling binaries on Windows:

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

No Compiler

All binary code is backed by a pure Python implementation. Compiling can be skipped using the flag --no-binary

pip install git+git://github.com/bashtage/arch.git --install-option "--no-binary"

Note: the test suite compares the Numba implementations against Cython implementations of some recursions, and so it is not possible to run the test suite when installing with --no-binary .

Anaconda

conda install -c https://conda.binstar.org/bashtage arch

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

arch-3.0.zip (107.0 kB view details)

Uploaded Source

arch-3.0.tar.bz2 (73.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

arch-3.0.win-amd64-py3.4.exe (429.3 kB view details)

Uploaded Source

arch-3.0.win-amd64-py3.3.exe (429.1 kB view details)

Uploaded Source

arch-3.0.win-amd64-py2.7.exe (439.1 kB view details)

Uploaded Source

arch-3.0-cp34-none-win_amd64.whl (204.4 kB view details)

Uploaded CPython 3.4Windows x86-64

arch-3.0-cp33-none-win_amd64.whl (204.3 kB view details)

Uploaded CPython 3.3Windows x86-64

arch-3.0-cp27-none-win_amd64.whl (212.7 kB view details)

Uploaded CPython 2.7Windows x86-64

File details

Details for the file arch-3.0.zip.

File metadata

  • Download URL: arch-3.0.zip
  • Upload date:
  • Size: 107.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for arch-3.0.zip
Algorithm Hash digest
SHA256 aa97a2635d6c042ec37e6321185072a720986491ea508fd046c31acb4bf5cbc7
MD5 05b6f3ce651f0e3a5680bc2c9acb5295
BLAKE2b-256 5e82dd7d2ccef91c871e6851cdce54dd2badcd1408edfadb12bbd1e2ae26eb64

See more details on using hashes here.

File details

Details for the file arch-3.0.tar.bz2.

File metadata

  • Download URL: arch-3.0.tar.bz2
  • Upload date:
  • Size: 73.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for arch-3.0.tar.bz2
Algorithm Hash digest
SHA256 83f006849caae8b8853d4fbe16ce125f48cc1b6ace741b3134a912bf413d09dd
MD5 b60861cd7d56cc56f1e6788aa0b61e45
BLAKE2b-256 9eb27acd84859e435ba9a646cf917d77a737b196896fd0de51f6f0b15edca97a

See more details on using hashes here.

File details

Details for the file arch-3.0.win-amd64-py3.4.exe.

File metadata

File hashes

Hashes for arch-3.0.win-amd64-py3.4.exe
Algorithm Hash digest
SHA256 b65f708758ac9e527ad30b04fe87c098293f07784b734fa9d26a19150ba76d0d
MD5 1c8ff22f4cdb7e874ab7ae30f3a14234
BLAKE2b-256 9a04d1be6888fff3d7ea32d03c9d60e03a697407ff4fd895210a0843f64e6439

See more details on using hashes here.

File details

Details for the file arch-3.0.win-amd64-py3.3.exe.

File metadata

File hashes

Hashes for arch-3.0.win-amd64-py3.3.exe
Algorithm Hash digest
SHA256 11cd5a78a9d1f823cfebb4244fdc669f81d996b112dfcc5bb35cd4f54f0eb3a0
MD5 098ff084cc38fa183361378fd58e3f14
BLAKE2b-256 37034d9d79dd116b5dc8ce63d634c6c3c4dbc3caf09e2b071448c0a773baa311

See more details on using hashes here.

File details

Details for the file arch-3.0.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for arch-3.0.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 b6995dd8da5eec9396dce3efb1127f8f51b2c3ffc1af40cf061c01533b7ce3aa
MD5 47f01a7855c134eadae9e2c45ffa9205
BLAKE2b-256 af01a07c1e7385fd7832f8b0c12c67c06ba25ab708d4e3425dbfb8067574f291

See more details on using hashes here.

File details

Details for the file arch-3.0-cp34-none-win_amd64.whl.

File metadata

  • Download URL: arch-3.0-cp34-none-win_amd64.whl
  • Upload date:
  • Size: 204.4 kB
  • Tags: CPython 3.4, Windows x86-64
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for arch-3.0-cp34-none-win_amd64.whl
Algorithm Hash digest
SHA256 e66228259c587c0217a5bd29ace16a966ee4d6f7c6b14f13b9cd6472296e4a5c
MD5 7f6770820ba3fb8f0f213086f09c76d3
BLAKE2b-256 f0a38313b2c7ffde024300b3bea812db24c2843bba0efaa7d41d8351cdba306f

See more details on using hashes here.

File details

Details for the file arch-3.0-cp33-none-win_amd64.whl.

File metadata

  • Download URL: arch-3.0-cp33-none-win_amd64.whl
  • Upload date:
  • Size: 204.3 kB
  • Tags: CPython 3.3, Windows x86-64
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for arch-3.0-cp33-none-win_amd64.whl
Algorithm Hash digest
SHA256 c3cb028511c26a4caedb3f8c0a61690f5c57a9f05c17746611d5df2077cc479f
MD5 2c0027b9dadfa199ebd670047f767ab3
BLAKE2b-256 f56b72601eec53a6ec9fcec09fed8813a6a5094c45bfd21c7365c975c7d4eef1

See more details on using hashes here.

File details

Details for the file arch-3.0-cp27-none-win_amd64.whl.

File metadata

  • Download URL: arch-3.0-cp27-none-win_amd64.whl
  • Upload date:
  • Size: 212.7 kB
  • Tags: CPython 2.7, Windows x86-64
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for arch-3.0-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 97b5d5a627799b93227f1118555b7a331e5b4b0677b3307037f1e772a3049889
MD5 23eea1e76c74f0e9e94e9610ece41448
BLAKE2b-256 6a6c92b20a4788212bb94451ce1a381d85c8d478195ac9166f07a33f863ab200

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