Add helper methods to construct iron condor strategy name strings for ensuring consistency between backtest and trades tables

This commit is contained in:
moshferatu 2024-02-15 08:18:15 -08:00
parent 8379184b62
commit d51bec8a46
2 changed files with 6 additions and 0 deletions

View File

@ -7,6 +7,9 @@ from .option_type import OptionType
class CreditTargetStrategy(OptionSpreadStrategy): class CreditTargetStrategy(OptionSpreadStrategy):
credit_target: float credit_target: float
def iron_condor_strategy(credit_target: float) -> str:
return f'${credit_target:.2f} Iron Condor'
def create_strategies(credit_target: float, entry_time: str, number_of_contracts: int = 1): def create_strategies(credit_target: float, entry_time: str, number_of_contracts: int = 1):
call_spread_strategy = CreditTargetStrategy( call_spread_strategy = CreditTargetStrategy(
credit_target = credit_target, credit_target = credit_target,

View File

@ -7,6 +7,9 @@ from .option_type import OptionType
class DeltaTargetStrategy(OptionSpreadStrategy): class DeltaTargetStrategy(OptionSpreadStrategy):
delta_target: float delta_target: float
def iron_condor_strategy(delta_target: float) -> str:
return f'{int(delta_target * 100)} Delta Iron Condor'
def create_strategies(delta_target: float, entry_time: str, number_of_contracts: int = 1): def create_strategies(delta_target: float, entry_time: str, number_of_contracts: int = 1):
call_spread_strategy = DeltaTargetStrategy( call_spread_strategy = DeltaTargetStrategy(
delta_target = delta_target, delta_target = delta_target,