Add the list of option legs to the order
This commit is contained in:
parent
e02167ab93
commit
a10783c737
@ -145,7 +145,7 @@ class Client:
|
||||
while not option_order.isDone():
|
||||
self.ib.waitOnUpdate()
|
||||
|
||||
return OptionOrder(option_order, leg_mid)
|
||||
return OptionOrder([leg], leg_mid, option_order)
|
||||
|
||||
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))
|
||||
@ -164,7 +164,7 @@ class Client:
|
||||
while not spread_order.isDone():
|
||||
self.ib.waitOnUpdate()
|
||||
|
||||
return OptionOrder(spread_order, spread_mid)
|
||||
return OptionOrder([near_leg, far_leg], spread_mid, spread_order)
|
||||
|
||||
def submit_stop_loss_order(self, trade: Trade, stop_loss_price: float, limit_price: float = None) -> Trade:
|
||||
stop_loss_order = Order()
|
||||
|
@ -1,8 +1,12 @@
|
||||
from ib_insync import Trade
|
||||
from typing import List
|
||||
|
||||
from .option_leg import OptionLeg
|
||||
|
||||
class OptionOrder:
|
||||
|
||||
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.mid_price = mid_price
|
||||
def __init__(self, legs: List[OptionLeg], mid_price: float, order_result: Trade):
|
||||
self.legs = legs
|
||||
self.mid_price = mid_price
|
||||
self.limit_price = abs(order_result.order.lmtPrice)
|
||||
self.fill_price = abs(order_result.orderStatus.avgFillPrice)
|
Loading…
Reference in New Issue
Block a user