计算分时图上均价线(黄色线)的代码例程
K线更新事件
def OnBar(context, code, bartype) :
klinedata = GetHisDataByField2(g.stock,["open", "close", "volume"], bar_type=BarType.Min, start_date=GetCurrentTradingDate('SHSE'))
g.pre_open = klinedata[0][-2] # 昨开
g.pre_close = klinedata[1][-2] # 昨收
# 量价相乘
g.volume_close = [v * c for v, c in zip(g.klinedata[0],g.klinedata[2])]
# 量价均线
g.volume_close_avg = [sum(g.volume_close[:i+1])/sum(g.klinedata[2][:i+1])
for i in range(len(g.volume_close))]
回复 0:
按时间排序
您尚未登录,请 登录 真格量化发表回复