Add some debug logs for tracking entry slippage based on the options chain since that data is coming from Tradestation while the order is submitted on IBKR
This commit is contained in:
parent
d868192002
commit
da58e44dda
@ -119,6 +119,12 @@ def _enter_iron_condor(entry_time: datetime):
|
||||
logging.info(f'Short Call Strike: {short_call_strike}')
|
||||
logging.info(f'Long Call Strike: {long_call_strike}')
|
||||
|
||||
put_spread_price = options_chain.spread_mid_price(short_put_strike, long_put_strike, OptionType.PUT)
|
||||
logging.info(f'Options Chain Put Spread Mid Price: {put_spread_price}')
|
||||
|
||||
call_spread_price = options_chain.spread_mid_price(short_call_strike, long_call_strike, OptionType.CALL)
|
||||
logging.info(f'Options Chain Call Spread Mid Price: {call_spread_price}')
|
||||
|
||||
ibkr_client = Client()
|
||||
trade = IronCondorTrade(symbol, credit_target, entry_time, float(getenv('STOP_MULTIPLE')))
|
||||
|
||||
@ -129,6 +135,7 @@ def _enter_iron_condor(entry_time: datetime):
|
||||
logging.info(f'Call Spread Mid Price: {call_spread_order.mid_price}')
|
||||
logging.info(f'Call Spread Fill Price: {call_spread_order.fill_price}')
|
||||
logging.info(f'Call Spread Slippage: {call_spread_order.mid_price - call_spread_order.fill_price}')
|
||||
logging.info(f'Options Chain Call Spread Slippage: {call_spread_price - call_spread_order.fill_price}')
|
||||
|
||||
monitor_spread_price(
|
||||
trade = trade,
|
||||
@ -145,6 +152,7 @@ def _enter_iron_condor(entry_time: datetime):
|
||||
logging.info(f'Put Spread Mid Price: {put_spread_order.mid_price}')
|
||||
logging.info(f'Put Spread Fill Price: {put_spread_order.fill_price}')
|
||||
logging.info(f'Put Spread Slippage: {put_spread_order.mid_price - put_spread_order.fill_price}')
|
||||
logging.info(f'Options Chain Put Spread Slippage: {put_spread_price - put_spread_order.fill_price}')
|
||||
|
||||
monitor_spread_price(
|
||||
trade = trade,
|
||||
|
@ -37,6 +37,18 @@ class OptionsChain:
|
||||
options['Strike Distance'] = abs(options['Strike'] - target_strike)
|
||||
return options.loc[options['Strike Distance'].idxmin()]
|
||||
|
||||
def spread_mid_price(self, near_strike: float, far_strike: float, option_type: OptionType):
|
||||
options = self.options_by_type(option_type)
|
||||
|
||||
near_leg = options[options['Strike'] == near_strike]
|
||||
far_leg = options[options['Strike'] == far_strike]
|
||||
|
||||
near_leg_mid = (near_leg['Ask'] + near_leg['Bid'].clip(lower = 0)) / 2.0
|
||||
far_leg_mid = (far_leg['Ask'] + far_leg['Bid'].clip(lower = 0)) / 2.0
|
||||
spread_mid = near_leg_mid.iloc[0] - far_leg_mid.iloc[0]
|
||||
|
||||
return spread_mid
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.options_chain.to_string()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user