From a0f9c1bf7b948238e23e2f2083eef1ea1074d181 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 6 Jan 2022 13:51:15 +0100 Subject: [PATCH] Avoid failure when calculating max-drawdown occurs if if no winning trade is recorded. --- freqtrade/data/btanalysis.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/data/btanalysis.py b/freqtrade/data/btanalysis.py index 4a9f69167..43d0f15f5 100644 --- a/freqtrade/data/btanalysis.py +++ b/freqtrade/data/btanalysis.py @@ -413,8 +413,9 @@ def calculate_max_drawdown(trades: pd.DataFrame, *, date_col: str = 'close_date' high_val = max_drawdown_df.loc[max_drawdown_df.iloc[:idxmin] ['high_value'].idxmax(), 'cumulative'] low_val = max_drawdown_df.loc[idxmin, 'cumulative'] - - max_drawdown_rel = (high_val - low_val) / (high_val + starting_balance) + max_drawdown_rel = 0.0 + if high_val + starting_balance != 0: + max_drawdown_rel = (high_val - low_val) / (high_val + starting_balance) return ( abs(min(max_drawdown_df['drawdown'])),