diff --git a/docs/backtesting.md b/docs/backtesting.md index 64480acd9..001941993 100644 --- a/docs/backtesting.md +++ b/docs/backtesting.md @@ -427,7 +427,7 @@ It contains some useful key metrics about performance of your strategy on backte - `Rejected Buy signals`: Buy signals that could not be acted upon due to max_open_trades being reached. - `Min balance` / `Max balance`: Lowest and Highest Wallet balance during the backtest period. - `Drawdown (Account)`: Maximum Account Drawdown experienced. Calculated as $(Absolute Drawdown) / (DrawdownHigh + startingBalance)$. -- `Drawdown`: Maximum, absolute drawdown experienced. Difference between Drawdown High and Low. +- `Drawdown`: Maximum, absolute drawdown experienced. Difference between Drawdown High and Subsequent Low point. - `Drawdown high` / `Drawdown low`: Profit at the beginning and end of the largest drawdown period. A negative low value means initial capital lost. - `Drawdown Start` / `Drawdown End`: Start and end datetime for this largest drawdown (can also be visualized via the `plot-dataframe` sub-command). - `Market change`: Change of the market during the backtest period. Calculated as average of all pairs changes from the first to the last candle using the "close" column. diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index 239b05a83..56ec51a56 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -207,10 +207,10 @@ def generate_strategy_comparison(all_results: Dict) -> List[Dict]: results['results'], results['config']['dry_run_wallet'], strategy) ) try: - max_drawdown_per, _, _, _, _ = calculate_max_drawdown(results['results'], - value_col='profit_ratio') - max_drawdown_abs, _, _, _, _ = calculate_max_drawdown(results['results'], - value_col='profit_abs') + max_drawdown_per, _, _, _, _, _ = calculate_max_drawdown(results['results'], + value_col='profit_ratio') + max_drawdown_abs, _, _, _, _, _ = calculate_max_drawdown(results['results'], + value_col='profit_abs') except ValueError: max_drawdown_per = 0 max_drawdown_abs = 0 @@ -719,7 +719,10 @@ def text_table_add_metrics(strat_results: Dict) -> str: ('Max balance', round_coin_value(strat_results['csum_max'], strat_results['stake_currency'])), - ('Drawdown (Account)', f"{strat_results['max_drawdown_account']:.2%}"), + # Compatibility to show old hyperopt results + ('Drawdown (Account)', f"{strat_results['max_drawdown_account']:.2%}") + if 'max_drawdown_account' in strat_results else ( + 'Drawdown', f"{strat_results['max_drawdown']:.2%}"), ('Drawdown', round_coin_value(strat_results['max_drawdown_abs'], strat_results['stake_currency'])), ('Drawdown high', round_coin_value(strat_results['max_drawdown_high'], diff --git a/tests/data/test_btanalysis.py b/tests/data/test_btanalysis.py index a571338c3..ca6912e2e 100644 --- a/tests/data/test_btanalysis.py +++ b/tests/data/test_btanalysis.py @@ -282,7 +282,7 @@ def test_create_cum_profit1(testdatadir): def test_calculate_max_drawdown(testdatadir): filename = testdatadir / "backtest-result_new.json" bt_data = load_backtest_data(filename) - drawdown_abs, hdate, lowdate, hval, lval, drawdown = calculate_max_drawdown( + _, hdate, lowdate, hval, lval, drawdown = calculate_max_drawdown( bt_data, value_col="profit_abs") assert isinstance(drawdown, float) assert pytest.approx(drawdown) == 0.59495234