Capitalize spread field names for the sake of consistency
This commit is contained in:
parent
05288fc235
commit
2335f6798c
@ -134,21 +134,21 @@ def _backtest_iron_condor(
|
||||
premium_received = original_call_spread_price + original_put_spread_price
|
||||
|
||||
call_spread_details = {
|
||||
"legs": [{"action": "SELL", "strike": call_spread_entry['strike_short_strike'], "type": "CALL"},
|
||||
{"action": "BUY", "strike": call_spread_entry['strike_long_strike'], "type": "CALL"}],
|
||||
"open": original_call_spread_price,
|
||||
"high": None,
|
||||
"low": None,
|
||||
"close": None
|
||||
"Legs": [{"Action": "SELL", "Strike": call_spread_entry['strike_short_strike'], "Type": "CALL"},
|
||||
{"Action": "BUY", "Strike": call_spread_entry['strike_long_strike'], "Type": "CALL"}],
|
||||
"Open": original_call_spread_price,
|
||||
"High": None,
|
||||
"Low": None,
|
||||
"Close": None
|
||||
}
|
||||
|
||||
put_spread_details = {
|
||||
"legs": [{"action": "SELL", "strike": put_spread_entry['strike_short_strike'], "type": "PUT"},
|
||||
{"action": "BUY", "strike": put_spread_entry['strike_long_strike'], "type": "PUT"}],
|
||||
"open": original_put_spread_price,
|
||||
"high": None,
|
||||
"low": None,
|
||||
"close": None
|
||||
"Legs": [{"Action": "SELL", "Strike": put_spread_entry['strike_short_strike'], "Type": "PUT"},
|
||||
{"Action": "BUY", "Strike": put_spread_entry['strike_long_strike'], "Type": "PUT"}],
|
||||
"Open": original_put_spread_price,
|
||||
"High": None,
|
||||
"Low": None,
|
||||
"Close": None
|
||||
}
|
||||
|
||||
trades_entered = False
|
||||
@ -185,18 +185,18 @@ def _backtest_iron_condor(
|
||||
else:
|
||||
current_put_spread_price = ((put_spread['ask_short_strike'] + put_spread['bid_short_strike']) / 2.0) - ((put_spread['ask_long_strike'] + put_spread['bid_long_strike']) / 2.0)
|
||||
|
||||
call_spread_details['high'] = max(call_spread_details['high'] or float('-inf'), current_call_spread_price)
|
||||
call_spread_details['low'] = min(call_spread_details['low'] or float('inf'), current_call_spread_price)
|
||||
call_spread_details['close'] = current_call_spread_price
|
||||
call_spread_details['High'] = max(call_spread_details['High'] or float('-inf'), current_call_spread_price)
|
||||
call_spread_details['Low'] = min(call_spread_details['Low'] or float('inf'), current_call_spread_price)
|
||||
call_spread_details['Close'] = current_call_spread_price
|
||||
|
||||
put_spread_details['high'] = max(put_spread_details['high'] or float('-inf'), current_put_spread_price)
|
||||
put_spread_details['low'] = min(put_spread_details['low'] or float('inf'), current_put_spread_price)
|
||||
put_spread_details['close'] = current_put_spread_price
|
||||
put_spread_details['High'] = max(put_spread_details['High'] or float('-inf'), current_put_spread_price)
|
||||
put_spread_details['Low'] = min(put_spread_details['Low'] or float('inf'), current_put_spread_price)
|
||||
put_spread_details['Close'] = current_put_spread_price
|
||||
|
||||
if not call_spread_stopped_out:
|
||||
if current_call_spread_price >= ((call_spread_strategy.stop_loss_multiple + 1) * original_call_spread_price):
|
||||
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
|
||||
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.
|
||||
call_spread_stopped_out = True
|
||||
@ -207,7 +207,7 @@ def _backtest_iron_condor(
|
||||
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.
|
||||
put_spread_details['close'] = original_put_spread_price * (put_spread_strategy.stop_loss_multiple + 1) + 0.10
|
||||
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:]
|
||||
logging.info('Put Spread Stopped Out')
|
||||
|
Loading…
Reference in New Issue
Block a user