From f56c6047ad3865b45e86a1ef3847e3b233c6a430 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Mon, 18 Nov 2024 23:04:07 +0100 Subject: [PATCH] [Kucoin] warn on fetch position without currencies --- Trading/Exchange/kucoin/kucoin_exchange.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Trading/Exchange/kucoin/kucoin_exchange.py b/Trading/Exchange/kucoin/kucoin_exchange.py index b3327b039..155feb0c7 100644 --- a/Trading/Exchange/kucoin/kucoin_exchange.py +++ b/Trading/Exchange/kucoin/kucoin_exchange.py @@ -288,10 +288,17 @@ async def get_balance(self, **kwargs: dict): if self.exchange_manager.is_future: # on futures, balance has to be fetched per currency # use gather to fetch everything at once (and not allow other requests to get in between) - await asyncio.gather(*( - self._update_balance(balance, currency, **kwargs) - for currency in self.exchange_manager.exchange_config.get_all_traded_currencies() - )) + currencies = self.exchange_manager.exchange_config.get_all_traded_currencies() + if not currencies: + self.logger.warning( + f"Can't fetch balance on {self.exchange_manager.exchange_name} futures when no traded currencies " + f"are set" + ) + else: + await asyncio.gather(*( + self._update_balance(balance, currency, **kwargs) + for currency in currencies + )) return balance return await super().get_balance(**kwargs)