从tushare上下载'002337'的数据
import tushare as ts data = ts.get_h_data('002337') data.to_csv('e:/stockData/002337.csv')
做ADF Test:
import pandas as pd import statsmodels.tsa.stattools as ts x = pd.read_csv('e:/stockData/002337.csv', encoding='utf-8', index_col='date') result = ts.adfuller(x.open, 1) print(result)
ADF检验结果
ADF Test Statistic -0.60992263732190832 p-value 0.8687241171140645 #Lags Used 1 Number of Observations Used 242 Critical Value(1%) -3.4576641321552009 Critical Value(5%) -2.8735585105960224 Critical Value(10%) -2.5731749894132916
p-value要小于0.05.等于0是最好的。平稳性好,非随机游走,可统计套利。
ADF Test Statistic要小于Critical Value,小于1%时平稳性最好,5%次之,依次类推。
如果ADF Test Statistic大于三个Critical Value,说明股价是随机游走的,无法进行统计套利,要寻找投资组合。
几篇文章http://www.cnblogs.com/foley/p/5582358.html
http://blog.sina.com.cn/s/blog_7439e81e0102vh59.html