From 766b2170532183cc4050060e491091e3952ead77 Mon Sep 17 00:00:00 2001 From: farmage Date: Mon, 4 Jul 2022 12:50:52 +0300 Subject: [PATCH] fix time for backtesting --- freqtrade/plugins/protections/trading_time.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/freqtrade/plugins/protections/trading_time.py b/freqtrade/plugins/protections/trading_time.py index 38b70ca8d..3402477c8 100644 --- a/freqtrade/plugins/protections/trading_time.py +++ b/freqtrade/plugins/protections/trading_time.py @@ -20,11 +20,11 @@ class TradingTime(IProtection): super().__init__(config, protection_config) self._start_time = datetime.strptime(protection_config.get('start_time', '00:00'), "%H:%M") self._end_time = datetime.strptime(protection_config.get('end_time', '23:59'), "%H:%M") - - self._update_trading_period() - - def _update_trading_period(self) -> None: now = datetime.now() + + self._update_trading_period(now) + + def _update_trading_period(self, now: datetime) -> None: self.trade_start, self.trade_end = ( now.replace(hour=self._start_time.hour, minute=self._start_time.minute, second=0), now.replace(hour=self._end_time.hour, minute=self._end_time.minute, second=0) @@ -49,8 +49,8 @@ class TradingTime(IProtection): """ Evaluate recent trades for drawdown ... """ - self._update_trading_period() - now = datetime.now() + now = date_now + self._update_trading_period(now) if not (self.trade_start < now < self.trade_end): return ProtectionReturn(