options-backtesting/backtest_iron_condor_example.py

26 lines
850 B
Python
Raw Normal View History

from backtesting import backtest_iron_condor
from backtesting.delta_targeting import create_strategies
from datetime import datetime
from plotting import BacktestChart, plot
if __name__ == '__main__':
start_date = datetime(2024, 1, 1)
end_date = datetime.now()
call_spread_strategy, put_spread_strategy = create_strategies(
delta_target = 0.10,
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)
plot(BacktestChart(
dates = backtest_result['Date'],
profit = backtest_result['Cumulative Profit'],
title = f'Iron Condor @ {call_spread_strategy.trade_entry_time}'
))