From b0fab3ad50c6f4a3ac86dd7b09a3b55df3cbf050 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 2 Apr 2022 15:36:25 +0200 Subject: [PATCH] Properly handle empty dataframes after trimming closes #6629 --- freqtrade/optimize/backtesting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index b63c404fc..9784d426c 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -339,14 +339,14 @@ class Backtesting: if col in df_analyzed.columns: df_analyzed.loc[:, col] = df_analyzed.loc[:, col].replace( [nan], [0 if not tag_col else None]).shift(1) - else: + elif not df_analyzed.empty: df_analyzed.loc[:, col] = 0 if not tag_col else None df_analyzed = df_analyzed.drop(df_analyzed.head(1).index) # Convert from Pandas to list for performance reasons # (Looping Pandas is slow.) - data[pair] = df_analyzed[headers].values.tolist() + data[pair] = df_analyzed[headers].values.tolist() if not df_analyzed.empty else [] return data def _get_close_rate(self, sell_row: Tuple, trade: LocalTrade, sell: ExitCheckTuple,