价差交易模块里的strategy定义了on_spread_tick方法,代码如下,策略启动后,并没有按照逻辑发出停止单,大佬们可以帮忙看一下问题在哪吗?
def on_spread_tick(self, tick: TickData):
"""
Callback when new spread tick data is generated.
"""
self.spread_pos = self.get_spread_pos()
if self.spread_pos > 0:
self.stop_open_algos()
# Start sell close algo (profit taking)
if (tick.last_price >= self.sell_price) and (not self.sell_algoid):
self.sell_algoid = self.start_short_algo(
self.sell_price, abs(
self.spread_pos), self.payup, self.interval
)
# Start stop close algo for long trading (stop loss)
elif (tick.last_price <= self.buy_stop_price) and (not self.buy_stop_algoid):
self.buy_stop_algoid = self.start_short_algo(
self.buy_stop_price, self.spread_pos, self.payup, self.interval
)
elif self.spread_pos < 0:
self.stop_open_algos()
# Start cover close algo (profit taking)
if (tick.last_price <= self.cover_price) and (not self.cover_algoid):
self.cover_algoid = self.start_long_algo(
self.cover_price, abs(
self.spread_pos), self.payup, self.interval
)
# Start stop close algo for short trading (stop loss)
elif (tick.last_price >= self.short_stop_price) and (not self.short_stop_algoid):
self.short_stop_algoid = self.start_long_algo(
self.short_stop_price, abs(
self.spread_pos), self.payup, self.interval
)
self.put_event()