- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 9911 个
- 通用积分
- 38.0729
- 学术水平
- 67 点
- 热心指数
- 67 点
- 信用等级
- 61 点
- 经验
- 1211 点
- 帖子
- 714
- 精华
- 3
- 在线时间
- 1562 小时
- 注册时间
- 2009-12-16
- 最后登录
- 2024-4-25
教授
还不是VIP/贵宾
TA的文库 其他... 投资理财书籍
- 威望
- 0 级
- 论坛币
- 9911 个
- 通用积分
- 38.0729
- 学术水平
- 67 点
- 热心指数
- 67 点
- 信用等级
- 61 点
- 经验
- 1211 点
- 帖子
- 714
- 精华
- 3
- 在线时间
- 1562 小时
- 注册时间
- 2009-12-16
- 最后登录
- 2024-4-25
| 开心 2022-1-10 16:08:57 |
---|
签到天数: 9 天 连续签到: 1 天 [LV.3]偶尔看看II
|
相似文件
换一批
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- #编写hurst指数
- from numpy import std, subtract, polyfit, sqrt, log
- import numpy as np
- import pandas as pd
- from matplotlib import pyplot as plt
- from datetime import timedelta
- from statsmodels import regression
- from lib.hurst import *
- data=DataAPI.MktIdxdGet(tradeDate=u"",indexID=u"000001.ZICN",ticker=u"",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:]
- #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)
- ma5_hhh=hhh.rolling(20).mean()
- ma20_hhh=hhh.rolling(100).mean()
- plt.plot(ma5_hhh)
- plt.plot(ma20_hhh)
- plt.show()
复制代码- fig,ax1=plt.subplots()
- data=data[221:]
- print len(data)
- 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)
- ma5_hhh=hhh.rolling(20).mean()
- ma20_hhh=hhh.rolling(100).mean()
- 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()
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
-
总评分: 经验 + 100
学术水平 + 1
热心指数 + 1
信用等级 + 1
查看全部评分
|