_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
|
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)
|
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()
|
until = self.calculate_unlock_at()
|
||||||
else:
|
else:
|
||||||
until = self.calculate_lock_end([trade], self._stop_duration)
|
until = self.calculate_lock_end([trade], self._stop_duration)
|
||||||
|
|||||||
@@ -33,22 +33,22 @@ class IProtection(LoggingMixin, ABC):
|
|||||||
self._protection_config = protection_config
|
self._protection_config = protection_config
|
||||||
self._stop_duration_candles: Optional[int] = None
|
self._stop_duration_candles: Optional[int] = None
|
||||||
self._lookback_period_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"])
|
tf_in_min = timeframe_to_minutes(config["timeframe"])
|
||||||
if "unlock_at" in protection_config:
|
if "stop_duration_candles" in protection_config:
|
||||||
self.unlock_at = self.calculate_unlock_at()
|
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:
|
else:
|
||||||
if "stop_duration_candles" in protection_config:
|
self._stop_duration = int(protection_config.get("stop_duration", 60))
|
||||||
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))
|
|
||||||
|
|
||||||
if "lookback_period_candles" in protection_config:
|
if "lookback_period_candles" in protection_config:
|
||||||
self._lookback_period_candles = int(protection_config.get("lookback_period_candles", 1))
|
self._lookback_period_candles = int(protection_config.get("lookback_period_candles", 1))
|
||||||
self._lookback_period = tf_in_min * self._lookback_period_candles
|
self._lookback_period = tf_in_min * self._lookback_period_candles
|
||||||
else:
|
else:
|
||||||
|
self._lookback_period_candles = None
|
||||||
self._lookback_period = int(protection_config.get("lookback_period", 60))
|
self._lookback_period = int(protection_config.get("lookback_period", 60))
|
||||||
|
|
||||||
LoggingMixin.__init__(self, logger)
|
LoggingMixin.__init__(self, logger)
|
||||||
@@ -88,8 +88,8 @@ class IProtection(LoggingMixin, ABC):
|
|||||||
"""
|
"""
|
||||||
Output configured unlock time
|
Output configured unlock time
|
||||||
"""
|
"""
|
||||||
if self.unlock_at:
|
if self._unlock_at:
|
||||||
return self.unlock_at.strftime("%H:%M")
|
return self._unlock_at.strftime("%H:%M")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def calculate_unlock_at(self) -> datetime:
|
def calculate_unlock_at(self) -> datetime:
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class LowProfitPairs(IProtection):
|
|||||||
logger.info,
|
logger.info,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.unlock_at is not None:
|
if self._unlock_at is not None:
|
||||||
until = self.calculate_unlock_at()
|
until = self.calculate_unlock_at()
|
||||||
else:
|
else:
|
||||||
until = self.calculate_lock_end(trades, self._stop_duration)
|
until = self.calculate_lock_end(trades, self._stop_duration)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class MaxDrawdown(IProtection):
|
|||||||
logger.info,
|
logger.info,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.unlock_at is not None:
|
if self._unlock_at is not None:
|
||||||
until = self.calculate_unlock_at()
|
until = self.calculate_unlock_at()
|
||||||
else:
|
else:
|
||||||
until = self.calculate_lock_end(trades, self._stop_duration)
|
until = self.calculate_lock_end(trades, self._stop_duration)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class StoplossGuard(IProtection):
|
|||||||
logger.info,
|
logger.info,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.unlock_at is not None:
|
if self._unlock_at is not None:
|
||||||
until = self.calculate_unlock_at()
|
until = self.calculate_unlock_at()
|
||||||
else:
|
else:
|
||||||
until = self.calculate_lock_end(trades, self._stop_duration)
|
until = self.calculate_lock_end(trades, self._stop_duration)
|
||||||
|
|||||||
Reference in New Issue
Block a user