From df932568b486e007fca44196ac59270a7078b7fd Mon Sep 17 00:00:00 2001 From: moshferatu Date: Tue, 20 Feb 2024 08:46:00 -0800 Subject: [PATCH] Track the spread mid prices and use them to obtain a more accurate measure of slippage --- iron_condor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/iron_condor.py b/iron_condor.py index cf73ff6..a525e87 100644 --- a/iron_condor.py +++ b/iron_condor.py @@ -123,11 +123,13 @@ def _enter_iron_condor(entry_time: datetime): long_call_leg = OptionLeg(symbol, expiration, long_call_strike, CALL, BUY, sub_symbol) call_spread_order = ibkr_client.submit_spread_order(short_call_leg, long_call_leg) + call_spread_mid = call_spread_order.mid_price call_spread_limit = call_spread_order.limit_price call_spread_fill = call_spread_order.fill_price + logging.info(f'Call Spread Mid Price: {call_spread_mid}') logging.info(f'Call Spread Limit Price: {call_spread_limit}') logging.info(f'Call Spread Fill Price: {call_spread_fill}') - logging.info(f'Call Spread Slippage: {call_spread_fill - call_spread_limit}') + logging.info(f'Call Spread Slippage: {call_spread_fill - call_spread_mid}') monitor_spread_price( short_leg = short_call_leg, @@ -140,11 +142,13 @@ def _enter_iron_condor(entry_time: datetime): long_put_leg = OptionLeg(symbol, expiration, long_put_strike, PUT, BUY, sub_symbol) put_spread_order = ibkr_client.submit_spread_order(short_put_leg, long_put_leg) + put_spread_mid = put_spread_order.mid_price put_spread_limit = put_spread_order.limit_price put_spread_fill = put_spread_order.fill_price + logging.info(f'Put Spread Mid Price: {put_spread_mid}') logging.info(f'Put Spread Limit Price: {put_spread_limit}') logging.info(f'Put Spread Fill Price: {put_spread_fill}') - logging.info(f'Put Spread Slippage: {put_spread_fill - put_spread_limit}') + logging.info(f'Put Spread Slippage: {put_spread_fill - put_spread_mid}') monitor_spread_price( short_leg = short_put_leg,