Skip to content

Commit

Permalink
[Kucoin] handle no given symbol balance fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Dec 1, 2024
1 parent 61107d9 commit e8b8068
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Trading/Exchange/kucoin/kucoin_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class Kucoin(exchanges.RestExchange):
("order does not exist",),
]

DEFAULT_BALANCE_CURRENCIES_TO_FETCH = ["USDT"]

@classmethod
def get_name(cls):
return 'kucoin'
Expand Down Expand Up @@ -290,15 +292,15 @@ async def get_balance(self, **kwargs: dict):
# use gather to fetch everything at once (and not allow other requests to get in between)
currencies = self.exchange_manager.exchange_config.get_all_traded_currencies()
if not currencies:
currencies = self.DEFAULT_BALANCE_CURRENCIES_TO_FETCH
self.logger.warning(
f"Can't fetch balance on {self.exchange_manager.exchange_name} futures when no traded currencies "
f"are set"
f"are set, fetching {currencies[0]} balance instead"
)
else:
await asyncio.gather(*(
self._update_balance(balance, currency, **kwargs)
for currency in currencies
))
await asyncio.gather(*(
self._update_balance(balance, currency, **kwargs)
for currency in currencies
))
return balance
return await super().get_balance(**kwargs)

Expand Down

0 comments on commit e8b8068

Please sign in to comment.