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))]