Add support for limit orders when submitting a combo option order

This commit is contained in:
moshferatu 2024-02-17 09:19:51 -08:00
parent f80ae0727e
commit e722eacd7a

View File

@ -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