options-backtesting/backtesting/credit_targeting.py

27 lines
930 B
Python

from dataclasses import dataclass
from .option_spread_strategy import OptionSpreadStrategy
from .option_type import OptionType
@dataclass
class CreditTargetStrategy(OptionSpreadStrategy):
credit_target: float
def create_strategies(credit_target: float, entry_time: str, number_of_contracts: int = 1):
call_spread_strategy = CreditTargetStrategy(
credit_target = credit_target,
option_type = OptionType.CALL,
number_of_contracts = number_of_contracts,
spread_width = 50,
stop_loss_multiple = 1.00,
trade_entry_time = entry_time
)
put_spread_strategy = CreditTargetStrategy(
credit_target = credit_target,
option_type = OptionType.PUT,
number_of_contracts = number_of_contracts,
spread_width = 50,
stop_loss_multiple = 1.00,
trade_entry_time = entry_time
)
return call_spread_strategy, put_spread_strategy