diff --git a/ibkr/client.py b/ibkr/client.py index 6ca6f5a..c662eb6 100644 --- a/ibkr/client.py +++ b/ibkr/client.py @@ -143,7 +143,7 @@ class Client: while not option_order.isDone(): self.ib.waitOnUpdate() - return OptionOrder(option_order) + return OptionOrder(option_order, leg_mid) def submit_spread_order(self, near_leg: OptionLeg, far_leg: OptionLeg) -> OptionOrder: near_leg_data = self.get_market_data(self.get_option_contract(near_leg)) @@ -160,7 +160,7 @@ class Client: while not spread_order.isDone(): self.ib.waitOnUpdate() - return OptionOrder(spread_order) + return OptionOrder(spread_order, spread_mid) def submit_stop_loss_order(self, trade: Trade, stop_loss_price: float, limit_price: float = None) -> Trade: stop_loss_order = Order() diff --git a/ibkr/option_order.py b/ibkr/option_order.py index 374e2e1..ae7283f 100644 --- a/ibkr/option_order.py +++ b/ibkr/option_order.py @@ -2,6 +2,7 @@ from ib_insync import Trade class OptionOrder: - def __init__(self, trade_result: Trade): + def __init__(self, trade_result: Trade, mid_price: float): self.limit_price = abs(trade_result.order.lmtPrice) - self.fill_price = abs(trade_result.orderStatus.avgFillPrice) \ No newline at end of file + self.fill_price = abs(trade_result.orderStatus.avgFillPrice) + self.mid_price = mid_price \ No newline at end of file