From 7b80f5e1383461fd78b509a39adc2de1e63083ae Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 18 Jan 2024 10:58:51 -0800 Subject: [PATCH] Send a Discord message when backtest automation fails --- backtest_scheduler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backtest_scheduler.py b/backtest_scheduler.py index 06d5626..4f8a99c 100644 --- a/backtest_scheduler.py +++ b/backtest_scheduler.py @@ -3,10 +3,15 @@ import time import traceback from datetime import datetime, timedelta +from discord_messaging import send_message +from dotenv import load_dotenv +from os import getenv from download_spx_quotes import download_quotes from run_backtest import run_backtest +load_dotenv() + def backtest_automation(): try: download_quotes() @@ -16,8 +21,7 @@ def backtest_automation(): start_date = end_date - timedelta(days = 1) run_backtest(start_date, end_date) except: - # TODO: Send Discord notification. - print('Error occurred during backtest automation.') + send_message('Backtest automation failed!', getenv('USER_ID')) traceback.print_exc() if __name__ == '__main__':