下面代码是vnpy自带的肯特纳通道突破的代码,请问下,这是在突破开仓的那一瞬间就挂上止损单? 还是要等走完开仓时的那根k线后才设止损单?
self.kk_up, self.kk_down = am.keltner(self.kk_length, self.kk_dev)
if self.pos == 0:
self.intra_trade_high = bar.high_price
self.intra_trade_low = bar.low_price
self.send_oco_order(self.kk_up, self.kk_down, self.fixed_size)
elif self.pos > 0:
self.intra_trade_high = max(self.intra_trade_high, bar.high_price)
self.intra_trade_low = bar.low_price
vt_orderids = self.sell(self.intra_trade_high * (1 - self.trailing_percent / 100),
abs(self.pos), True)
self.vt_orderids.extend(vt_orderids)
elif self.pos < 0:
self.intra_trade_high = bar.high_price
self.intra_trade_low = min(self.intra_trade_low, bar.low_price)
vt_orderids = self.cover(self.intra_trade_low * (1 + self.trailing_percent / 100),
abs(self.pos), True)
self.vt_orderids.extend(vt_orderids)