diff --git a/docs/hyperopt.md b/docs/hyperopt.md index bab062fad..030d73f4b 100644 --- a/docs/hyperopt.md +++ b/docs/hyperopt.md @@ -566,7 +566,7 @@ Currently, the following loss functions are builtin: * `SortinoHyperOptLoss` - optimizes Sortino Ratio calculated on trade returns relative to **downside** standard deviation. * `SortinoHyperOptLossDaily` - optimizes Sortino Ratio calculated on **daily** trade returns relative to **downside** standard deviation. * `MaxDrawDownHyperOptLoss` - Optimizes Maximum absolute drawdown. -* `MaxDrawDownRelativeHyperOptLoss` - Similar as the above, but also optimizes Maximum relative drawdown. +* `MaxDrawDownRelativeHyperOptLoss` - Optimizes both maximum absolute drawdown while also adjusting for maximum relative drawdown. * `CalmarHyperOptLoss` - Optimizes Calmar Ratio calculated on trade returns relative to max drawdown. * `ProfitDrawDownHyperOptLoss` - Optimizes by max Profit & min Drawdown objective. `DRAWDOWN_MULT` variable within the hyperoptloss file can be adjusted to be stricter or more flexible on drawdown purposes. diff --git a/freqtrade/data/metrics.py b/freqtrade/data/metrics.py index 5e93ae0dc..79d192f83 100644 --- a/freqtrade/data/metrics.py +++ b/freqtrade/data/metrics.py @@ -153,7 +153,7 @@ def calculate_max_drawdown(trades: pd.DataFrame, *, date_col: str = 'close_date' max_drawdown_rel = max_drawdown_df.loc[idxmin, 'drawdown_relative'] return ( - abs(min(max_drawdown_df['drawdown'])), + abs(max_drawdown_df.loc[idxmin, 'drawdown']), high_date, low_date, high_val, diff --git a/tests/data/test_btanalysis.py b/tests/data/test_btanalysis.py index 2cfc33b6b..4157bd899 100644 --- a/tests/data/test_btanalysis.py +++ b/tests/data/test_btanalysis.py @@ -380,7 +380,7 @@ def test_calculate_max_drawdown2(): @pytest.mark.parametrize('profits,relative,highd,lowd,result,result_rel', [ ([0.0, -500.0, 500.0, 10000.0, -1000.0], False, 3, 4, 1000.0, 0.090909), - ([0.0, -500.0, 500.0, 10000.0, -1000.0], True, 0, 1, 1000.0, 0.5), + ([0.0, -500.0, 500.0, 10000.0, -1000.0], True, 0, 1, 500.0, 0.5), ]) def test_calculate_max_drawdown_abs(profits, relative, highd, lowd, result, result_rel):