-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This package provides a set of ARCH model with AR and HAR mean dynamics
- Loading branch information
0 parents
commit 5a74b3a
Showing
42 changed files
with
8,120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Travis script that uses miniconda in place of the system installed python | ||
# versions. Allows substantial flexability for choosing versions of | ||
# required packages and is simpler to use to test up-to-date scientific Python | ||
# stack | ||
language: python | ||
|
||
env: | ||
# Default values for common packages, override as needed | ||
global: | ||
- CYTHON=0.20 | ||
- PATSY=0.2 | ||
- PANDAS= | ||
- OPTIONAL= | ||
- STATSMODELS= | ||
- COVERAGE=true | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- python: 2.7 | ||
env: | ||
- PYTHON=2.7 | ||
- NUMPY=1.7 | ||
- SCIPY=0.12 | ||
- python: 2.7 | ||
env: | ||
- PYTHON=3.3 | ||
- NUMPY=1.8 | ||
- SCIPY=0.14 | ||
- PANDAS=0.14 | ||
- COVERAGE=false | ||
|
||
notifications: | ||
email: | ||
on_success: always | ||
|
||
# Setup anaconda | ||
before_install: | ||
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh | ||
- chmod +x miniconda.sh | ||
- ./miniconda.sh -b | ||
- export PATH=/home/travis/miniconda/bin:$PATH | ||
- sudo apt-get install pandoc | ||
- conda update --yes --quiet conda | ||
# Fix for headless TravisCI | ||
- "export DISPLAY=:99.0" | ||
- "sh -e /etc/init.d/xvfb start" | ||
# Avoid noise from matplotlib | ||
- mkdir $HOME/.config | ||
- mkdir $HOME/.config/matplotlib | ||
|
||
# Install packages | ||
install: | ||
- conda create --yes --quiet -n arch-test python=${PYTHON} numpy=${NUMPY} scipy=${SCIPY} ipython-notebook statsmodels dateutil nose pip pyyaml setuptools Cython numba matplotlib | ||
- source activate arch-test | ||
- if [ ${COVERAGE} = true ]; then pip install coverage coveralls nose-cov; fi | ||
- python setup.py build | ||
|
||
script: | ||
- SRCDIR=$PWD | ||
- python setup.py install | ||
# Show versions | ||
- mkdir -p "${SRCDIR}/travis-test"; cd "${SRCDIR}/travis-test" | ||
- python -c 'import statsmodels.api as sm; sm.show_versions();' | ||
- echo 'import arch; a=arch.test(); import sys; sys.exit((len(a.failures)+len(a.errors))>0)' > test.py | ||
- if [ ${COVERAGE} = true ]; then coverage run --rcfile=${SRCDIR}/.travis_coveragerc test.py; else python test.py; fi | ||
|
||
after_success: | ||
- if [ ${COVERAGE} = true ]; then coveralls --rcfile=${SRCDIR}/.travis_coveragerc; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# .coveragerc to control coverage.py | ||
[run] | ||
source = arch | ||
branch = True | ||
include = */arch/* | ||
omit = *test_*.py | ||
|
||
[report] | ||
# Regexes for lines to exclude from consideration | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise NotImplementedError | ||
except NotImplementedError | ||
# Ignore pass | ||
pass | ||
include = */arch/* | ||
omit = *test_*.py,*/compat/*,*recursions.py | ||
ignore_errors = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
**Copyright (c) 2014 Kevin Sheppard. All rights reserved.** | ||
|
||
Developed by: Kevin Sheppard (<[email protected]>, | ||
<[email protected]>) | ||
[http://www.kevinsheppard.com](http://www.kevinsheppard.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal with | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimers. | ||
|
||
Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimers in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
Neither the names of Kevin Sheppard, nor the names of its contributors may be | ||
used to endorse or promote products derived from this Software without specific | ||
prior written permission. | ||
|
||
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH | ||
THE SOFTWARE.** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
[![Documentation Status](https://readthedocs.org/projects/arch/badge/?version=latest)](https://readthedocs.org/projects/arch/?badge=latest) | ||
[![CI Status](https://travis-ci.org/bashtage/arch.svg?branch=master)](https://travis-ci.org/bashtage/arch) | ||
[![Coverage Status](https://coveralls.io/repos/bashtage/arch/badge.png?branch=master)](https://coveralls.io/r/bashtage/arch?branch=master) | ||
|
||
|
||
# ARCH | ||
|
||
This is a work-in-progress for ARCH and related models, written in Python | ||
(and Cython) | ||
|
||
## What is this repository for? | ||
|
||
* Mean models | ||
* Constant mean | ||
* Heterogeneous Autoregression (HAR) | ||
* Autoregression (AR) | ||
* Zero mean | ||
* Models with and without exogensou regressors | ||
* Volatility models | ||
* ARCH | ||
* GARCH | ||
* TARCH | ||
* EGARCH | ||
* EWMA/RiskMetrics | ||
* Distributions | ||
* Normal | ||
* Student's T | ||
|
||
## Examples | ||
|
||
See the [example notebook](http://nbviewer.ipython.org/github/bashtage/arch/blob/master/examples/Examples.ipynb) | ||
for a more complete overview. | ||
|
||
```python | ||
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() | ||
``` | ||
|
||
## Documentation | ||
Documentation is hosted on [read the docs](http://arch.readthedocs.org/en/latest/) | ||
|
||
## Requirements | ||
|
||
* NumPy (1.7+) | ||
* SciPy (0.12+) | ||
* Pandas (0.14+) | ||
* statsmodels (0.5+) | ||
* matplotlib (1.3+) | ||
|
||
Installing | ||
* Cython (0.20+) | ||
* nose (For tests) | ||
* sphinx (to build docs) | ||
* sphinx-napoleon (to build docs) | ||
|
||
## Installing | ||
|
||
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 that it isn't possible to run the test suite will fail if installed with_ `--no-binary` | ||
|
||
**Anaconda** | ||
|
||
``` | ||
conda install -c https://conda.binstar.org/bashtage arch | ||
``` | ||
|
||
## More about ARCH | ||
More information about ARCH and related models is available in the notes and | ||
research available at [Kevin Sheppard's site](http://www.kevinsheppard.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os | ||
|
||
from numpy.testing import Tester | ||
|
||
from .mean import arch_model | ||
from ._version import __version__ | ||
|
||
test = Tester().test | ||
|
||
def doc(): | ||
import webbrowser | ||
webbrowser.open('http://arch.readthedocs.org/en/latest/') | ||
|
Oops, something went wrong.