以上是原文,看源代码如下,我在非交易时间允许代码
def on_bar(self, context, bars, symbol, flag):
print(bars[len(bars)-1])
代码输出一直如下。从输出看,应该是初始化成功了,但为什么没有On_Bar事件的驱动?
on_init success.
Position(broker_id =482, account_id = 66121741, symbol = rb2605.SHFE, l_current_volume=0, l_yesterday_volume=0, l_active_volume=0, l_active_close_volume=0, l_can_sell_volume=0, l_market_value=0.000000, l_avg_price=0.000000, l_float_porfit=0.000000, l_avg_price_o=0.000000, l_float_porfit_o=0.000000, l_use_margin_amount=0.000000, s_current_volume=5, s_yesterday_volume=5, s_active_volume=0, s_active_close_volume=0, s_can_cover_volume=5, s_market_value=153400.000000, s_avg_price=3070.000000, s_float_porfit=100.000000, s_avg_price_o=3157.200000, s_float_porfit_o=4460.000000, s_use_margin_amount=16117.500000)
sliding_window|int|数据滑窗大小(on_bar每次回调的bar数),默认1,
请版主解释以上数据滑窗大小的意义是什么?看到_slow_length=10,这是什么意思?
ret = context.subscribe_bar(symbol=self._symbol, frequency='10s', begin_time=datetime.datetime.now()-datetime.timedelta(minutes=self._slow_length), sliding_window=self._slow_length)
可能是begin_time在非交易时段,可以改一下开始时间,跨度多一些试试
on_bar函数和TB中OnBar(ArrayRef<Integer> indexs) 有什么区别?
和TB代码中的OnBar(ArrayRef<Integer> indexs) 有什么区别?