diff --git a/freqtrade/plugins/protections/cooldown_period.py b/freqtrade/plugins/protections/cooldown_period.py index 30a611189..d9fb5b9a6 100644 --- a/freqtrade/plugins/protections/cooldown_period.py +++ b/freqtrade/plugins/protections/cooldown_period.py @@ -54,7 +54,7 @@ class CooldownPeriod(IProtection): trade = sorted(trades, key=lambda t: t.close_date)[-1] # type: ignore self.log_once(f"Cooldown for {pair} for {self.stop_duration_str}.", logger.info) - if self.unlock_at is not None: + if self._unlock_at is not None: until = self.calculate_unlock_at() else: until = self.calculate_lock_end([trade], self._stop_duration) diff --git a/freqtrade/plugins/protections/iprotection.py b/freqtrade/plugins/protections/iprotection.py index bf86caefe..709d03354 100644 --- a/freqtrade/plugins/protections/iprotection.py +++ b/freqtrade/plugins/protections/iprotection.py @@ -33,22 +33,22 @@ class IProtection(LoggingMixin, ABC): self._protection_config = protection_config self._stop_duration_candles: Optional[int] = None self._lookback_period_candles: Optional[int] = None - self.unlock_at: Optional[datetime] = None + self._unlock_at: Optional[datetime] = None tf_in_min = timeframe_to_minutes(config["timeframe"]) - if "unlock_at" in protection_config: - self.unlock_at = self.calculate_unlock_at() + if "stop_duration_candles" in protection_config: + self._stop_duration_candles = int(protection_config.get("stop_duration_candles", 1)) + self._stop_duration = tf_in_min * self._stop_duration_candles + elif "unlock_at" in protection_config: + self._unlock_at = self.calculate_unlock_at() else: - if "stop_duration_candles" in protection_config: - self._stop_duration_candles = int(protection_config.get("stop_duration_candles", 1)) - self._stop_duration = tf_in_min * self._stop_duration_candles - else: - self._stop_duration = int(protection_config.get("stop_duration", 60)) + self._stop_duration = int(protection_config.get("stop_duration", 60)) if "lookback_period_candles" in protection_config: self._lookback_period_candles = int(protection_config.get("lookback_period_candles", 1)) self._lookback_period = tf_in_min * self._lookback_period_candles else: + self._lookback_period_candles = None self._lookback_period = int(protection_config.get("lookback_period", 60)) LoggingMixin.__init__(self, logger) @@ -88,8 +88,8 @@ class IProtection(LoggingMixin, ABC): """ Output configured unlock time """ - if self.unlock_at: - return self.unlock_at.strftime("%H:%M") + if self._unlock_at: + return self._unlock_at.strftime("%H:%M") return None def calculate_unlock_at(self) -> datetime: diff --git a/freqtrade/plugins/protections/low_profit_pairs.py b/freqtrade/plugins/protections/low_profit_pairs.py index b997254ab..88554d2be 100644 --- a/freqtrade/plugins/protections/low_profit_pairs.py +++ b/freqtrade/plugins/protections/low_profit_pairs.py @@ -73,7 +73,7 @@ class LowProfitPairs(IProtection): logger.info, ) - if self.unlock_at is not None: + if self._unlock_at is not None: until = self.calculate_unlock_at() else: until = self.calculate_lock_end(trades, self._stop_duration) diff --git a/freqtrade/plugins/protections/max_drawdown_protection.py b/freqtrade/plugins/protections/max_drawdown_protection.py index 264ad57d0..1816df303 100644 --- a/freqtrade/plugins/protections/max_drawdown_protection.py +++ b/freqtrade/plugins/protections/max_drawdown_protection.py @@ -76,7 +76,7 @@ class MaxDrawdown(IProtection): logger.info, ) - if self.unlock_at is not None: + if self._unlock_at is not None: until = self.calculate_unlock_at() else: until = self.calculate_lock_end(trades, self._stop_duration) diff --git a/freqtrade/plugins/protections/stoploss_guard.py b/freqtrade/plugins/protections/stoploss_guard.py index f36a2f157..0ef2254e8 100644 --- a/freqtrade/plugins/protections/stoploss_guard.py +++ b/freqtrade/plugins/protections/stoploss_guard.py @@ -81,7 +81,7 @@ class StoplossGuard(IProtection): logger.info, ) - if self.unlock_at is not None: + if self._unlock_at is not None: until = self.calculate_unlock_at() else: until = self.calculate_lock_end(trades, self._stop_duration)