Add test for cooldown period

This commit is contained in:
Matthias
2020-10-24 20:25:40 +02:00
parent fe0afb9883
commit 8dbef6bbea
2 changed files with 46 additions and 5 deletions

View File

@@ -1,9 +1,8 @@
import logging
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from typing import Any, Dict
from freqtrade.persistence import Trade
from freqtrade.plugins.protections import IProtection, ProtectionReturn
@@ -28,7 +27,7 @@ class CooldownPeriod(IProtection):
"""
Short method description - used for startup-messages
"""
return (f"{self.name} - Cooldown period.")
return (f"{self.name} - Cooldown period of {self._stopduration} min.")
def _cooldown_period(self, pair: str, date_now: datetime, ) -> ProtectionReturn:
"""
@@ -43,7 +42,8 @@ class CooldownPeriod(IProtection):
trade = Trade.get_trades(filters).first()
if trade:
self.log_on_refresh(logger.info, f"Cooldown for {pair} for {self._stopduration}.")
until = trade.close_date + timedelta(minutes=self._stopduration)
until = trade.close_date.replace(
tzinfo=timezone.utc) + timedelta(minutes=self._stopduration)
return True, until, self._reason()
return False, None, None