Skip to content

Commit 5a74b3a

Browse files
committed
ENH: ARCH models in Python
This package provides a set of ARCH model with AR and HAR mean dynamics
0 parents  commit 5a74b3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+8120
-0
lines changed

.travis.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Travis script that uses miniconda in place of the system installed python
2+
# versions. Allows substantial flexability for choosing versions of
3+
# required packages and is simpler to use to test up-to-date scientific Python
4+
# stack
5+
language: python
6+
7+
env:
8+
# Default values for common packages, override as needed
9+
global:
10+
- CYTHON=0.20
11+
- PATSY=0.2
12+
- PANDAS=
13+
- OPTIONAL=
14+
- STATSMODELS=
15+
- COVERAGE=true
16+
17+
matrix:
18+
fast_finish: true
19+
include:
20+
- python: 2.7
21+
env:
22+
- PYTHON=2.7
23+
- NUMPY=1.7
24+
- SCIPY=0.12
25+
- python: 2.7
26+
env:
27+
- PYTHON=3.3
28+
- NUMPY=1.8
29+
- SCIPY=0.14
30+
- PANDAS=0.14
31+
- COVERAGE=false
32+
33+
notifications:
34+
email:
35+
on_success: always
36+
37+
# Setup anaconda
38+
before_install:
39+
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
40+
- chmod +x miniconda.sh
41+
- ./miniconda.sh -b
42+
- export PATH=/home/travis/miniconda/bin:$PATH
43+
- sudo apt-get install pandoc
44+
- conda update --yes --quiet conda
45+
# Fix for headless TravisCI
46+
- "export DISPLAY=:99.0"
47+
- "sh -e /etc/init.d/xvfb start"
48+
# Avoid noise from matplotlib
49+
- mkdir $HOME/.config
50+
- mkdir $HOME/.config/matplotlib
51+
52+
# Install packages
53+
install:
54+
- conda create --yes --quiet -n arch-test python=${PYTHON} numpy=${NUMPY} scipy=${SCIPY} ipython-notebook statsmodels dateutil nose pip pyyaml setuptools Cython numba matplotlib
55+
- source activate arch-test
56+
- if [ ${COVERAGE} = true ]; then pip install coverage coveralls nose-cov; fi
57+
- python setup.py build
58+
59+
script:
60+
- SRCDIR=$PWD
61+
- python setup.py install
62+
# Show versions
63+
- mkdir -p "${SRCDIR}/travis-test"; cd "${SRCDIR}/travis-test"
64+
- python -c 'import statsmodels.api as sm; sm.show_versions();'
65+
- echo 'import arch; a=arch.test(); import sys; sys.exit((len(a.failures)+len(a.errors))>0)' > test.py
66+
- if [ ${COVERAGE} = true ]; then coverage run --rcfile=${SRCDIR}/.travis_coveragerc test.py; else python test.py; fi
67+
68+
after_success:
69+
- if [ ${COVERAGE} = true ]; then coveralls --rcfile=${SRCDIR}/.travis_coveragerc; fi

.travis_coveragerc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# .coveragerc to control coverage.py
2+
[run]
3+
source = arch
4+
branch = True
5+
include = */arch/*
6+
omit = *test_*.py
7+
8+
[report]
9+
# Regexes for lines to exclude from consideration
10+
exclude_lines =
11+
# Have to re-enable the standard pragma
12+
pragma: no cover
13+
14+
# Don't complain if tests don't hit defensive assertion code:
15+
raise NotImplementedError
16+
except NotImplementedError
17+
# Ignore pass
18+
pass
19+
include = */arch/*
20+
omit = *test_*.py,*/compat/*,*recursions.py
21+
ignore_errors = True

LICENSE.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
**Copyright (c) 2014 Kevin Sheppard. All rights reserved.**
2+
3+
Developed by: Kevin Sheppard (<[email protected]>,
4+
5+
[http://www.kevinsheppard.com](http://www.kevinsheppard.com)
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
this software and associated documentation files (the "Software"), to deal with
9+
the Software without restriction, including without limitation the rights to
10+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11+
of the Software, and to permit persons to whom the Software is furnished to do
12+
so, subject to the following conditions:
13+
14+
Redistributions of source code must retain the above copyright notice, this
15+
list of conditions and the following disclaimers.
16+
17+
Redistributions in binary form must reproduce the above copyright notice, this
18+
list of conditions and the following disclaimers in the documentation and/or
19+
other materials provided with the distribution.
20+
21+
Neither the names of Kevin Sheppard, nor the names of its contributors may be
22+
used to endorse or promote products derived from this Software without specific
23+
prior written permission.
24+
25+
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28+
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
31+
THE SOFTWARE.**

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include VERSION

README.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
[![Documentation Status](https://readthedocs.org/projects/arch/badge/?version=latest)](https://readthedocs.org/projects/arch/?badge=latest)
2+
[![CI Status](https://travis-ci.org/bashtage/arch.svg?branch=master)](https://travis-ci.org/bashtage/arch)
3+
[![Coverage Status](https://coveralls.io/repos/bashtage/arch/badge.png?branch=master)](https://coveralls.io/r/bashtage/arch?branch=master)
4+
5+
6+
# ARCH
7+
8+
This is a work-in-progress for ARCH and related models, written in Python
9+
(and Cython)
10+
11+
## What is this repository for?
12+
13+
* Mean models
14+
* Constant mean
15+
* Heterogeneous Autoregression (HAR)
16+
* Autoregression (AR)
17+
* Zero mean
18+
* Models with and without exogensou regressors
19+
* Volatility models
20+
* ARCH
21+
* GARCH
22+
* TARCH
23+
* EGARCH
24+
* EWMA/RiskMetrics
25+
* Distributions
26+
* Normal
27+
* Student's T
28+
29+
## Examples
30+
31+
See the [example notebook](http://nbviewer.ipython.org/github/bashtage/arch/blob/master/examples/Examples.ipynb)
32+
for a more complete overview.
33+
34+
```python
35+
import datetime as dt
36+
import pandas.io.data as web
37+
st = dt.datetime(1990,1,1)
38+
en = dt.datetime(2014,1,1)
39+
data = web.get_data_yahoo('^FTSE', start=st, end=en)
40+
returns = 100 * data['Adj Close'].pct_change().dropna()
41+
42+
from arch import arch_model
43+
am = arch_model(returns)
44+
res = am.fit()
45+
```
46+
47+
## Documentation
48+
Documentation is hosted on [read the docs](http://arch.readthedocs.org/en/latest/)
49+
50+
## Requirements
51+
52+
* NumPy (1.7+)
53+
* SciPy (0.12+)
54+
* Pandas (0.14+)
55+
* statsmodels (0.5+)
56+
* matplotlib (1.3+)
57+
58+
Installing
59+
* Cython (0.20+)
60+
* nose (For tests)
61+
* sphinx (to build docs)
62+
* sphinx-napoleon (to build docs)
63+
64+
## Installing
65+
66+
Setup does not verify requirements. Please ensure these are installed.
67+
68+
### Linux/OSX
69+
70+
```
71+
pip install git+git://github.com/bashtage/arch.git
72+
```
73+
74+
**Anaconda**
75+
76+
_Anaconda builds are not currently available for OSX._
77+
78+
```
79+
conda install -c https://conda.binstar.org/bashtage arch
80+
```
81+
82+
### Windows
83+
84+
**With a compiler**
85+
86+
If you are comfortable compiling binaries on Windows:
87+
88+
```
89+
pip install git+git://github.com/bashtage/arch.git
90+
```
91+
92+
**No Compiler**
93+
94+
All binary code is backed by a pure Python implementation. Compiling can be
95+
skipped using the flag `--no-binary`
96+
97+
```
98+
pip install git+git://github.com/bashtage/arch.git --install-option "--no-binary"
99+
```
100+
101+
_Note that it isn't possible to run the test suite will fail if installed with_ `--no-binary`
102+
103+
**Anaconda**
104+
105+
```
106+
conda install -c https://conda.binstar.org/bashtage arch
107+
```
108+
109+
## More about ARCH
110+
More information about ARCH and related models is available in the notes and
111+
research available at [Kevin Sheppard's site](http://www.kevinsheppard.com).

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0

arch/__init__.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
from numpy.testing import Tester
4+
5+
from .mean import arch_model
6+
from ._version import __version__
7+
8+
test = Tester().test
9+
10+
def doc():
11+
import webbrowser
12+
webbrowser.open('http://arch.readthedocs.org/en/latest/')
13+

0 commit comments

Comments
 (0)