Add mid price to the option order in order to more accurately determine the incurred slippage
This commit is contained in:
parent
7c9837f3d2
commit
8f48ff6950
@ -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()
|
||||
|
@ -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)
|
||||
self.fill_price = abs(trade_result.orderStatus.avgFillPrice)
|
||||
self.mid_price = mid_price
|
Loading…
Reference in New Issue
Block a user