From e722eacd7a877473b2f32a368b2e25e995ef1f55 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sat, 17 Feb 2024 09:19:51 -0800 Subject: [PATCH] Add support for limit orders when submitting a combo option order --- ibkr/client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ibkr/client.py b/ibkr/client.py index 81dec18..9ba2c9d 100644 --- a/ibkr/client.py +++ b/ibkr/client.py @@ -93,7 +93,7 @@ class Client: return self.ib.placeOrder(contract, order) - def submit_combo_option_order(self, legs: List[OptionLeg], quantity: int) -> Trade: + def submit_combo_option_order(self, legs: List[OptionLeg], quantity: int, limit_price: float = None) -> Trade: combo_legs = [] for leg in legs: option_contract = self.get_option_contract(leg) @@ -113,7 +113,13 @@ class Client: combo_order = Order() combo_order.action = BUY # TODO: Document the logic behind this. - combo_order.orderType = 'MKT' # TODO: Limit order support. + + if limit_price is None: + combo_order.orderType = 'MKT' + else: + combo_order.orderType = 'LMT' + combo_order.lmtPrice = limit_price + combo_order.totalQuantity = quantity combo_order.transmit = True