From 1402ab88cc07456ea57388156dd5fbc197a79544 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sun, 21 Jan 2024 05:56:06 -0800 Subject: [PATCH] Verify whether the backtest result data frame contains data before attempting to drop the cumulative profit column --- run_backtest.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/run_backtest.py b/run_backtest.py index 87e196c..3b33279 100644 --- a/run_backtest.py +++ b/run_backtest.py @@ -50,10 +50,12 @@ def run_backtest(start_date: datetime, end_date: datetime): start_date, end_date ) - # TODO: Think of a better way to handle this. - backtest_results.drop('Cumulative Profit', axis = 1, inplace = True) - print(backtest_results) - insert(backtest_results) + + if not backtest_results.empty: + # TODO: Think of a better way to handle this. + backtest_results.drop('Cumulative Profit', axis = 1, inplace = True) + print(backtest_results) + insert(backtest_results) if __name__ == '__main__': # TODO: Update backtest to eliminate the need for setting this to midnight.