TBPY例子:双均线交易,为什么没有on_bar事件的打印信息

https://tbpy.tbquant.net/helper?product_id=810&keyword=3606&content_id=2433&selectedkey=3684&type=article

以上是原文,看源代码如下,我在非交易时间允许代码

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)


TBPY on_order事件没有推送
使用帮助文档中的示例双均线交易策略报错
双均线问题
双均线参数优化
双均线交易5日破10线
双均线平仓问题
双均线系统设置止损报错
条件满足,打印成功,但为什么没有出现交易信号
双均线策略问题
根据视频课写了EMA的双均线系统,但是图上没有信号,麻烦看看

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) 有什么区别?