Run example backtest for the previous day

This commit is contained in:
moshferatu 2024-01-18 06:28:08 -08:00
parent abe318db56
commit e3cae9d8a7

View File

@ -40,10 +40,7 @@ def create_strategies(entry_time: str):
) )
return call_spread_strat, put_spread_strat return call_spread_strat, put_spread_strat
def run_backtest(): def run_backtest(start_date: datetime, end_date: datetime):
# TODO: Start date = yesterday.
start_date = datetime(2024, 1, 1)
end_date = datetime.now()
for entry_time in entry_times(): for entry_time in entry_times():
call_spread_strategy, put_spread_strategy = create_strategies(entry_time) call_spread_strategy, put_spread_strategy = create_strategies(entry_time)
backtest_results = backtest_iron_condor( backtest_results = backtest_iron_condor(
@ -59,4 +56,7 @@ def run_backtest():
insert(backtest_results) insert(backtest_results)
if __name__ == '__main__': if __name__ == '__main__':
run_backtest() # TODO: Update backtest to eliminate the need for setting this to midnight.
end_date = datetime.now().replace(hour = 0, minute = 0, second = 0, microsecond = 0)
start_date = end_date - timedelta(days = 1)
run_backtest(start_date, end_date)