From 04976658da1303b99f377f3b98c5ccd5ac17a99a Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 7 Jan 2022 17:32:13 +0100 Subject: [PATCH] Fix crash when using backtesting-show on a old backtestresult --- freqtrade/optimize/optimize_reports.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index 17d1d8128..d0ffe49a9 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -642,7 +642,12 @@ def text_table_strategy(strategy_results, stake_currency: str) -> str: headers.append('Drawdown') # Align drawdown string on the center two space separator. - drawdown = [f'{t["max_drawdown_account"] * 100:.2f}' for t in strategy_results] + if 'max_drawdown_account' in strategy_results[0]: + drawdown = [f'{t["max_drawdown_account"] * 100:.2f}' for t in strategy_results] + else: + # Support for prior backtest results + drawdown = [f'{t["max_drawdown_per"]:.2f}' for t in strategy_results] + dd_pad_abs = max([len(t['max_drawdown_abs']) for t in strategy_results]) dd_pad_per = max([len(dd) for dd in drawdown]) drawdown = [f'{t["max_drawdown_abs"]:>{dd_pad_abs}} {stake_currency} {dd:>{dd_pad_per}}%'