from backtesting import backtest_iron_condor, DeltaTargetStrategy, OptionType from datetime import datetime 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, 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 = DeltaTargetStrategy( delta_upper_bound = 0.11, delta_lower_bound = 0.10, 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 if __name__ == '__main__': start_date = datetime(2024, 1, 12) end_date = datetime.now() call_spread_strategy, put_spread_strategy = create_strategies(entry_time = '10:05:00') backtest_result = backtest_iron_condor( f'Iron Condor @ {call_spread_strategy.trade_entry_time}', call_spread_strategy, put_spread_strategy, start_date, end_date ) print(backtest_result) # TODO: Move plot() to plotting module. # plot(backtest_result, title = 'Iron Condor Backtest Results')