mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-09 07:40:40 +00:00
_unlock_at should be private
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user