diff --git a/ibkr/client.py b/ibkr/client.py index 9ba2c9d..f69228b 100644 --- a/ibkr/client.py +++ b/ibkr/client.py @@ -125,10 +125,16 @@ class Client: return self.ib.placeOrder(combo_contract, combo_order) - def submit_stop_loss_order(self, trade: Trade, stop_loss_price): + def submit_stop_loss_order(self, trade: Trade, stop_loss_price: float, limit_price: float = None) -> Trade: stop_loss_order = Order() stop_loss_order.action = SELL if trade.order.action == BUY else BUY - stop_loss_order.orderType = 'STP' + + if limit_price is None: + stop_loss_order.orderType = 'STP' + else: + stop_loss_order.orderType = 'STP LMT' + stop_loss_order.lmtPrice = limit_price + stop_loss_order.auxPrice = stop_loss_price stop_loss_order.totalQuantity = trade.order.totalQuantity stop_loss_order.transmit = True