Remove bounding information from delta targeting strategy and instead use a fixed target
This commit is contained in:
parent
ea46e6dd13
commit
527bca9682
@ -4,8 +4,7 @@ from plotting import BacktestChart, plot
|
||||
|
||||
def create_strategies(entry_time: str, number_of_contracts: int = 1):
|
||||
call_spread_strategy = DeltaTargetStrategy(
|
||||
delta_upper_bound = 0.11,
|
||||
delta_lower_bound = 0.10,
|
||||
delta_target = 0.10,
|
||||
option_type = OptionType.CALL,
|
||||
number_of_contracts = number_of_contracts,
|
||||
spread_width = 50,
|
||||
@ -13,8 +12,7 @@ def create_strategies(entry_time: str, number_of_contracts: int = 1):
|
||||
trade_entry_time = entry_time
|
||||
)
|
||||
put_spread_strategy = DeltaTargetStrategy(
|
||||
delta_upper_bound = 0.11,
|
||||
delta_lower_bound = 0.10,
|
||||
delta_target = -0.10,
|
||||
option_type = OptionType.PUT,
|
||||
number_of_contracts = number_of_contracts,
|
||||
spread_width = 50,
|
||||
@ -24,7 +22,7 @@ def create_strategies(entry_time: str, number_of_contracts: int = 1):
|
||||
return call_spread_strategy, put_spread_strategy
|
||||
|
||||
if __name__ == '__main__':
|
||||
start_date = datetime(2024, 1, 12)
|
||||
start_date = datetime(2024, 1, 1)
|
||||
end_date = datetime.now()
|
||||
call_spread_strategy, put_spread_strategy = create_strategies(entry_time = '10:05:00')
|
||||
backtest_result = backtest_iron_condor(
|
||||
|
@ -74,13 +74,8 @@ def get_spread_history(historical_option_data: pd.DataFrame, option_strat: Delta
|
||||
if opening_quotes.empty:
|
||||
return None
|
||||
else:
|
||||
if option_strat.option_type == OptionType.PUT:
|
||||
opening_quotes['delta_diff'] = (opening_quotes['delta'] + option_strat.delta_upper_bound).abs()
|
||||
short_contract = opening_quotes.loc[opening_quotes['delta_diff'].idxmin()]
|
||||
else:
|
||||
opening_quotes['delta_diff'] = (opening_quotes['delta'] - option_strat.delta_upper_bound).abs()
|
||||
short_contract = opening_quotes.loc[opening_quotes['delta_diff'].idxmin()]
|
||||
|
||||
opening_quotes['delta_diff'] = (opening_quotes['delta'] - option_strat.delta_target).abs()
|
||||
short_contract = opening_quotes.loc[opening_quotes['delta_diff'].idxmin()]
|
||||
short_strike = short_contract['strike']
|
||||
logging.info('Short Strike: %s', short_strike)
|
||||
|
||||
|
@ -4,6 +4,4 @@ from .option_spread_strategy import OptionSpreadStrategy
|
||||
|
||||
@dataclass
|
||||
class DeltaTargetStrategy(OptionSpreadStrategy):
|
||||
# TODO: Just search closest delta instead.
|
||||
delta_upper_bound: float
|
||||
delta_lower_bound: float
|
||||
delta_target: float
|
Loading…
Reference in New Issue
Block a user