2024-02-04 13:56:28 +00:00
|
|
|
from backtesting import backtest_iron_condor
|
|
|
|
from backtesting.delta_targeting import create_strategies
|
2024-01-17 19:37:37 +00:00
|
|
|
from datetime import datetime
|
2024-01-30 19:17:46 +00:00
|
|
|
from plotting import BacktestChart, plot
|
2024-01-17 19:37:37 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2024-02-01 13:56:47 +00:00
|
|
|
start_date = datetime(2024, 1, 1)
|
2024-01-17 19:37:37 +00:00
|
|
|
end_date = datetime.now()
|
2024-02-04 13:56:28 +00:00
|
|
|
call_spread_strategy, put_spread_strategy = create_strategies(
|
|
|
|
delta_target = 0.10,
|
|
|
|
entry_time = '10:05:00'
|
|
|
|
)
|
2024-01-17 19:37:37 +00: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)
|
2024-01-30 19:17:46 +00:00
|
|
|
|
|
|
|
plot(BacktestChart(
|
|
|
|
dates = backtest_result['Date'],
|
|
|
|
profit = backtest_result['Cumulative Profit'],
|
|
|
|
title = f'Iron Condor @ {call_spread_strategy.trade_entry_time}'
|
|
|
|
))
|