Improve startup sequence to avoid certain timing errors

closes #9639
This commit is contained in:
Matthias 2024-01-05 17:26:25 +01:00
parent ec1b2e1da5
commit e7eb1c132d

View File

@ -83,6 +83,8 @@ class FreqtradeBot(LoggingMixin):
PairLocks.timeframe = self.config['timeframe'] PairLocks.timeframe = self.config['timeframe']
self.pairlists = PairListManager(self.exchange, self.config) self.pairlists = PairListManager(self.exchange, self.config)
self.trading_mode: TradingMode = self.config.get('trading_mode', TradingMode.SPOT)
self.last_process: Optional[datetime] = None
# RPC runs in separate threads, can start handling external commands just after # RPC runs in separate threads, can start handling external commands just after
# initialization, even before Freqtradebot has a chance to start its throttling, # initialization, even before Freqtradebot has a chance to start its throttling,
@ -119,8 +121,6 @@ class FreqtradeBot(LoggingMixin):
self._exit_lock = Lock() self._exit_lock = Lock()
LoggingMixin.__init__(self, logger, timeframe_to_seconds(self.strategy.timeframe)) LoggingMixin.__init__(self, logger, timeframe_to_seconds(self.strategy.timeframe))
self.trading_mode: TradingMode = self.config.get('trading_mode', TradingMode.SPOT)
self._schedule = Scheduler() self._schedule = Scheduler()
if self.trading_mode == TradingMode.FUTURES: if self.trading_mode == TradingMode.FUTURES:
@ -135,7 +135,6 @@ class FreqtradeBot(LoggingMixin):
for minutes in [1, 31]: for minutes in [1, 31]:
t = str(time(time_slot, minutes, 2)) t = str(time(time_slot, minutes, 2))
self._schedule.every().day.at(t).do(update) self._schedule.every().day.at(t).do(update)
self.last_process: Optional[datetime] = None
self.strategy.ft_bot_start() self.strategy.ft_bot_start()
# Initialize protections AFTER bot start - otherwise parameters are not loaded. # Initialize protections AFTER bot start - otherwise parameters are not loaded.