1月28日,成都市民刘可从中国农业银行四川省分行营业部走出来,手里拿着小纸包着的刚刚兑换到的5枚猴年贺岁纪念币。“3月,属猴的儿子就要出生了,准备把纪念币收藏起来为宝宝讨个彩头、留个纪念。”
<strong>天气:白天晴间多云有轻雾,南风2-3级,降水概率20%;夜间晴转多云,南风2-3级,降水概率20%。最高温度11℃,最低3℃。
def cci(stock,start_date,end_date,windows): #设置股票,起始时间,以及CCI指标多少日
import pandas as pd
import numpy as np
from CAL.PyCAL import *
Alpha = 0.015
eq_TP = {}
eq_MATP = {}
eq_meanDev = {}
eq_CCI = {}
cal = Calendar('China.SSE')
windows = '-'+str(windows)+'B'
start_date = Date.strptime(start_date,"%Y%m%d")
end_date = Date.strptime(end_date,"%Y%m%d")
timeLength = cal.bizDatesList(start_date, end_date)
for i in xrange(len(timeLength)):
begin_date = cal.advanceDate(timeLength[i],windows,BizDayConvention.Unadjusted)
begin_date =begin_date.strftime("%Y%m%d")
timeLength[i] = timeLength[i].strftime("%Y%m%d")
eq_static = DataAPI.MktEqudAdjGet(secID=stock,beginDate=begin_date,endDate=timeLength[i],field=['secID','highestPrice','lowestPrice','closePrice'],pandas="1")
for stk in stock:
try:
eq_TP[stk] = np.array(eq_static[eq_static['secID'] == stk].mean(axis=1))
eq_MATP[stk] = sum(eq_TP[stk])/len(eq_TP[stk])
eq_meanDev[stk] = sum(abs(eq_TP[stk] - eq_MATP[stk]))/len(eq_TP[stk])
eq_CCI[stk].append((eq_TP[stk][-1] - eq_MATP[stk])/(Alpha * eq_meanDev[stk]))
except:
eq_CCI[stk] = []
Date = pd.DataFrame(timeLength)
eq_CCI = pd.DataFrame(eq_CCI)
cciSeries = pd.concat([Date,eq_CCI],axis =1)
cciSeries.columns = ['Date','CCI']
return cciSeries