获取10日内每日最大成交量的简单平均值的代码例程
初始化事件
def OnMarketQuotationInitialEx(context, exchange, daynight) :
if exchange != 'SHSE': return
# 获取当月平值期权驱动OnQuote
klinedata = GetHisData2(g.stock,BarType.Day, count=2400, weight_type=1)
lastclose = klinedata[-1].close
g.atmopc = GetAtmOptionContract(g.stock, 0, lastclose, 0)
SubscribeQuote(g.atmopc)
SubscribeBar(g.stock, BarType.Day)
# 获取10日内每日最大成交量的简单平均值
k_volume = GetHisDataByField2(g.stock,["volume"], bar_type=BarType.Min, count=2400)
max_vol_sum = 0 # 最大成交量平均值
for i in range(len(k_volume[:]-1)) :
if (i + 1) % 240 == 0 and i < len(k_volume[:] - 1) :
max_vol_sum += max(k_volume[i - 238:i + 2])
g.max_vol_sum_avg = max_vol_sum / 10
回复 0:
按时间排序
您尚未登录,请 登录 真格量化发表回复