Initial commit of backtest scheduler job

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

27
backtest_scheduler.py Normal file
View File

@ -0,0 +1,27 @@
import schedule
import time
import traceback
from datetime import datetime, timedelta
from download_spx_quotes import download_quotes
from run_backtest import run_backtest
def backtest_automation():
try:
download_quotes()
# 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)
except:
# TODO: Send Discord notification.
print('Error occurred during backtest automation.')
traceback.print_exc()
if __name__ == '__main__':
schedule.every().day.at('03:00', 'America/Los_Angeles').do(backtest_automation)
while True:
schedule.run_pending()
time.sleep(1)