做策略回测,请问这里是该用self.cancel_all()还是self.cancel_order?
之前看到一个帖子https://www.vnpy.com/forum/topic/5927-che-dan-zai-gua?page=1#pid20762,实盘用 self.cancel_all()好像会出问题
# 当前无仓位,则直接开多
if self.pos == 0:
self.buy(price_1, 1)
self.buy(price_2, 1)
self.buy(price_3, 2)
# 当前持有1手,挂单平仓
elif self.pos = 1:
self.cancel_all()
self.cover(price_4, 1)
# 当前持有2手,撤单,重新挂单平仓
elif self.pos = 2:
self.cancel_all()
self.cover(price_5, 2)
# 当前持有4手,撤单,重新挂单平仓
elif self.pos = 4:
self.cancel_all()
self.cover(price_6, 4)