From 37c3ebe1fa5000d135aca789b4a1ccb9c8f6e964 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 7 Mar 2024 12:58:59 -0800 Subject: [PATCH] Incorporate more realistic slippage into entries and exits --- backtesting/backtest_iron_condor.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backtesting/backtest_iron_condor.py b/backtesting/backtest_iron_condor.py index 1a0a927..ee18224 100644 --- a/backtesting/backtest_iron_condor.py +++ b/backtesting/backtest_iron_condor.py @@ -111,11 +111,13 @@ def _backtest_iron_condor( # Calculate entry slippage. if original_call_spread_price > 0.05: - original_call_spread_price = original_call_spread_price - (original_call_spread_price % 0.05) + original_call_spread_price = original_call_spread_price - 0.10 + original_call_spread_price -= (original_call_spread_price % 0.05) logging.info('Original Call Spread Price: %s', original_call_spread_price) if original_put_spread_price > 0.05: - original_put_spread_price = original_put_spread_price - (original_put_spread_price % 0.05) + original_put_spread_price = original_put_spread_price - 0.10 + original_put_spread_price -= (original_put_spread_price % 0.05) logging.info('Original Put Spread Price: %s', original_put_spread_price) premium_received = original_call_spread_price + original_put_spread_price @@ -183,7 +185,7 @@ def _backtest_iron_condor( premium_received -= original_call_spread_price * (call_spread_strategy.stop_loss_multiple + 1) call_spread_details['Close'] = original_call_spread_price * (call_spread_strategy.stop_loss_multiple + 1) + 0.10 # Calculate exit slippage. - premium_received -= 0.10 # TODO: Make this configurable. + premium_received -= 0.20 # TODO: Make this configurable. call_spread_stopped_out = True exit_time = call_spread.name[-8:] logging.info('Call Spread Stopped Out') @@ -191,7 +193,7 @@ def _backtest_iron_condor( if not put_spread_stopped_out: if current_put_spread_price >= ((put_spread_strategy.stop_loss_multiple + 1) * original_put_spread_price): premium_received -= original_put_spread_price * (put_spread_strategy.stop_loss_multiple + 1) - premium_received -= 0.10 # TODO: Make this configurable. + premium_received -= 0.20 # TODO: Make this configurable. put_spread_details['Close'] = original_put_spread_price * (put_spread_strategy.stop_loss_multiple + 1) + 0.10 put_spread_stopped_out = True exit_time = call_spread.name[-8:]