diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 813938f99..dc17f6217 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -170,7 +170,9 @@ class Exchange: def close(self): logger.debug("Exchange object destroyed, closing async loop") - if self._api_async and inspect.iscoroutinefunction(self._api_async.close): + if (self._api_async and inspect.iscoroutinefunction(self._api_async.close) + and self._api_async.session): + logger.info("Closing async ccxt session.") asyncio.get_event_loop().run_until_complete(self._api_async.close()) def _init_ccxt(self, exchange_config: Dict[str, Any], ccxt_module: CcxtModuleType = ccxt, diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index fff187ef9..6f9acf930 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -126,6 +126,7 @@ class FreqtradeBot(LoggingMixin): self.rpc.cleanup() cleanup_db() + self.exchange.close() def startup(self) -> None: """