我的策略要同时用到一分钟和五分钟的K线,在策略文件中是这么写的,是哪里错了吗? self.put_event()是on_bar和on_5_min_bar下面都要加吗?
def init(self, cta_engine, strategy_name, vt_symbol, setting):
""""""
super().init(cta_engine, strategy_name, vt_symbol, setting)
self.bg1 = BarGenerator(self.on_bar)
self.am1 = ArrayManager()
self.bg5 = BarGenerator(self.on_bar, 5, self.on_5_min_bar)
self.am5 = ArrayManager()
def on_tick(self, tick: TickData):
"""
Callback of new tick data update.
"""
self.bg1.update_tick(tick)
self.bgx.update_tick(tick)
def on_bar(self, bar: BarData):
"""
Callback of new bar data update.
"""
self.bg1.update_bar(bar)
self.bg5.update_bar(bar)
if not self.am1.inited:
return
def on_5_min_bar(self, bar: BarData):
""""""
self.cancel_all()
self.am5.update_bar(bar)
if not self.am5.inited:
return