forked from alexanu/Python_Trading_Snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
augmentedDickeyFullerTest.py
27 lines (22 loc) · 1.07 KB
/
augmentedDickeyFullerTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#==========================================================
#============= augmentedDickeyFullerTest.py ===============
#==========================================================
# Purpose
#----------------------------------------------------------
# Identifying if a price series has a degree of mean reversion inherent in it
# is a very valuable tool in quantitative and algorithmic finance. One
# way of statistically making this determination is via the Augmented
# Dickey-Full (ADF) Test. This program leverages statsmodels and pandas
# library to output the results of the ADF test for a given input ticker
from __future__ import print_function
from datetime import datetime
import statsmodels.tsa.stattools as ts
import pandas.io.data as web
# Perform statsmodels ADF test on an input ticker from yahoo data
# TODO: dates should be prompted commandline inputs
if __name__ == "__main__":
import sys
ticker = str(sys.argv[1])
series = web.DataReader(ticker, "yahoo", datetime(2000,1,1), datetime(2015,1,1))
dat = ts.adfuller(series['Adj Close'], 1)
print(dat)