python-优矿-hurst指数与期货33品种的预测
来源:互联网 发布:怎么取消淘宝退款申请 编辑:程序博客网 时间:2024/04/27 17:34
#编写hurst指数from numpy import std, subtract, polyfit, sqrt, logimport numpy as npimport pandas as pdfrom matplotlib import pyplot as pltfrom datetime import timedeltafrom statsmodels import regressionfrom lib.hurst import *#data=DataAPI.MktIdxdGet(tradeDate=u"",indexID=u"",ticker=u"000300",beginDate=u"",endDate=u"",exchangeCD=u"XSHE,XSHG",field=u"",pandas="1")['closeIndex'][-1500:]#data=DataAPI.MktEqudGet(tradeDate=u"",secID=u"",ticker=u"000001",beginDate=u"",endDate=u"",isOpen="",field=u"",pandas="1")['closePrice'][-1500:]def get_hurst(data): #data=data[-500:] #data.index=range(len(data)) hhh=[] for i in range(len(data)): if i>220 : new_data=data[i-220:i] hhh.append(hurst(new_data,5)) #hhh=pd.Series(hhh) #ma1_hhh=hhh.rolling(1).mean() #ma5_hhh=hhh.rolling(20).mean() #ma20_hhh=hhh.rolling(100).mean() #plt.plot(ma1_hhh) #plt.plot(ma5_hhh) #plt.plot(ma20_hhh) #plt.show() fig,ax1=plt.subplots() data=data[221:] data.index=range(len(data)) data.plot(figsize=(10,4),color='red',linewidth=1) plt.grid(True) plt.ylabel("Index") plt.axis('tight') ax2=ax1.twinx() hhh=pd.Series(hhh) ma1_hhh=hhh.rolling(1).mean() ma5_hhh=hhh.rolling(20).mean() ma20_hhh=hhh.rolling(100).mean() ma1_hhh.plot(figsize=(10,4),color='black',linewidth=1,marker='.') ma5_hhh.plot(figsize=(10,4),color='green',linewidth=1,marker='.') ma20_hhh.plot(figsize=(10,4),color='blue',linewidth=1,marker='.') plt.grid(True) plt.ylabel('Hurst Index') plt.axis('tight') plt.show() return hhhnamelist=list_files(path='./期货指数')for i in namelist: filename='./期货指数/'+i data=pd.read_csv(filename,encoding='gbk') data=data.ix[::,4] print i[:2] get_hurst(data)
计算hurst指数对期货品种的效果,如果仅仅从hurst=0.5的角度看,随机游走的很少。大部分时间应该介于均值回归或者趋势中。下次用随机游走检验,adf检验下期货品种的有效性
阅读全文
0 0
- python-优矿-hurst指数与期货33品种的预测
- python-33品种期货自相关系数
- 时间序列中Hurst指数的计算(python代码)
- python-期货指数的单位根检验
- 广义Hurst指数与分维D关系的范例解释
- 指数期货
- R语言 Hurst指数计算
- python构建指数平滑预测模型
- 股票指数期货
- 联播大业王恒:国债期货上市后的三种股票有望成为流行品种
- 【原创】从文华财经下载数据并且分析每个期货品种的贝塔值-云金杞
- 基于Python的期货公司后台业务思考与实践
- python-33品种随机游走检验
- 电吉他效果器的品种与用途
- 期货多品种多策略多周期组合
- [量亿数据-指数-期货数据]沙特不减产与石油市场博弈论
- 个股与指数的回归分析(python)
- python-检验33品种数据是否是正态分布
- Mysqldump参数大全(参数来源于mysql5.5.19源码)
- hdu 1518 BFS
- hihocoder 最小生成树二·Kruscal算法
- Volley 请求后台数据中文乱码问题解决
- 常用控件(ProgressBar,Toggle,Switch,SeekBar,RatingBar)解析
- python-优矿-hurst指数与期货33品种的预测
- Oracle操作语句之DML语句
- 静态分析C语言生成函数调用关系的利器——calltree
- 断言3
- 四大基本组件之ContentProvider联系人
- destoon 手机版注册成功后 自动登录不了
- Android获取系统联系人
- Apache Log4j配置说明/log4j的分层打印
- 回调函数 oc.share.share