2024-01-18 14:28:39 +00:00
|
|
|
import schedule
|
|
|
|
import time
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta
|
2024-01-18 18:58:51 +00:00
|
|
|
from discord_messaging import send_message
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from os import getenv
|
2024-01-18 14:28:39 +00:00
|
|
|
|
|
|
|
from download_spx_quotes import download_quotes
|
2024-02-15 16:37:18 +00:00
|
|
|
from run_backtest import run_backtests
|
2024-01-18 14:28:39 +00:00
|
|
|
|
2024-01-18 18:58:51 +00:00
|
|
|
load_dotenv()
|
|
|
|
|
2024-01-18 14:28:39 +00:00
|
|
|
def backtest_automation():
|
|
|
|
try:
|
|
|
|
download_quotes()
|
|
|
|
|
2024-02-15 14:27:13 +00:00
|
|
|
end_date = datetime.now()
|
2024-01-18 14:28:39 +00:00
|
|
|
start_date = end_date - timedelta(days = 1)
|
2024-02-15 16:37:18 +00:00
|
|
|
run_backtests(start_date, end_date)
|
2024-01-18 14:28:39 +00:00
|
|
|
except:
|
2024-01-19 15:40:37 +00:00
|
|
|
send_message('Backtest automation failed!', to_user_id = getenv('USER_ID'))
|
2024-01-18 14:28:39 +00:00
|
|
|
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)
|