From d27aef2063ed20c22d4bcdd5aa4bc5dca8d4847c Mon Sep 17 00:00:00 2001 From: ABS <53243996+ABSllk@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:59:02 +0800 Subject: [PATCH] fix: correct parameter naming --- docs/includes/protections.md | 2 +- freqtrade/plugins/protections/max_drawdown_protection.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/includes/protections.md b/docs/includes/protections.md index 795478745..0a37f8d10 100644 --- a/docs/includes/protections.md +++ b/docs/includes/protections.md @@ -72,7 +72,7 @@ def protections(self): `MaxDrawdown` calculates the maximum relative drawdown using the account's equity curve within the `lookback_period` in minutes (or in candles when using `lookback_period_candles`). It evaluates the portfolio's peak-to-trough declines by considering the starting balance and the cumulative profit of all trades within the window. If the observed drawdown exceeds `max_allowed_drawdown`, trading will stop for `stop_duration` after the last trade - assuming that the bot needs some time to let markets recover. -The default calculation method is the sum-of-profit-ratios method (`method: "ratios"`) for backward compatibility. To use the standard peak-to-trough equity drawdown (recommended), set `method: "equity"`. +The default calculation method is the sum-of-profit-ratios method (`calculation_mode: "ratios"`) for backward compatibility. To use the standard peak-to-trough equity drawdown (recommended), set `calculation_mode: "equity"`. The below sample stops trading for 12 candles if max-drawdown is > 20% considering all pairs - with a minimum of `trade_limit` trades - within the last 48 candles. If desired, `lookback_period` and/or `stop_duration` can be used. diff --git a/freqtrade/plugins/protections/max_drawdown_protection.py b/freqtrade/plugins/protections/max_drawdown_protection.py index 77e8dfe58..6f80acf22 100644 --- a/freqtrade/plugins/protections/max_drawdown_protection.py +++ b/freqtrade/plugins/protections/max_drawdown_protection.py @@ -22,6 +22,7 @@ class MaxDrawdown(IProtection): self._trade_limit = protection_config.get("trade_limit", 1) self._max_allowed_drawdown = protection_config.get("max_allowed_drawdown", 0.0) + self._calculation_mode = protection_config.get("calculation_mode", "ratios") # TODO: Implement checks to limit max_drawdown to sensible values def short_desc(self) -> str: @@ -61,11 +62,8 @@ class MaxDrawdown(IProtection): if trade.close_date_utc <= look_back_until ) - # Get calculation mode - method = self._protection_config.get("method", "ratios") - try: - if method == "equity": + if self._calculation_mode == "equity": # Standard equity-based drawdown trades_df = pd.DataFrame( [