diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index c852f53b2..384ac43a1 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -563,6 +563,13 @@ class Exchange: amount, self.get_precision_amount(pair), self.precisionMode, contract_size ) + def ws_connection_reset(self): + """ + called at regular intervals to reset the websocket connection + """ + if self._exchange_ws: + self._exchange_ws.reset_connections() + def _load_async_markets(self, reload: bool = False) -> None: try: if self._api_async: diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 8d53097a5..9945296fa 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -168,6 +168,8 @@ class FreqtradeBot(LoggingMixin): t = str(time(time_slot, minutes, 2)) self._schedule.every().day.at(t).do(update) + self._schedule.every().day.at("00:02").do(self.exchange.ws_connection_reset) + self.strategy.ft_bot_start() # Initialize protections AFTER bot start - otherwise parameters are not loaded. self.protections = ProtectionManager(self.config, self.strategy.protections) @@ -289,8 +291,7 @@ class FreqtradeBot(LoggingMixin): # Then looking for entry opportunities if self.get_free_open_trades(): self.enter_positions() - if self.trading_mode == TradingMode.FUTURES: - self._schedule.run_pending() + self._schedule.run_pending() Trade.commit() self.rpc.process_msg_queue(self.dataprovider._msg_queue) self.last_process = datetime.now(timezone.utc)