Skip to content

Commit

Permalink
Updated Shared interfaces GetBalancesAsync to check if there are diff…
Browse files Browse the repository at this point in the history
…erent account type balances
  • Loading branch information
JKorf committed Jan 8, 2025
1 parent 2c499ac commit 99f4a07
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Kucoin.Net/Clients/SpotApi/KucoinRestClientSpotApiShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,19 @@ async Task<ExchangeWebResult<IEnumerable<SharedBalance>>> IBalanceRestClient.Get

var hfAccount = ExchangeParameters.GetValue<bool?>(request.ExchangeParameters, Exchange, "HfTrading");
var data = result.Data;
if (hfAccount == false)
data = result.Data.Where(x => x.Type == AccountType.Trade);
if (data.Any(x => x.Type == AccountType.Trade) && data.Any(x => x.Type == AccountType.SpotHf))
{
// If there are both Trade and SpotHF balance present check which to take
if (hfAccount == false)
data = result.Data.Where(x => x.Type == AccountType.Trade);
else
data = result.Data.Where(x => x.Type == AccountType.SpotHf);
}
else
data = result.Data.Where(x => x.Type == AccountType.SpotHf);
{
// If only Trade or Spot HF balance are available use that
data = result.Data.Where(x => x.Type == AccountType.SpotHf || x.Type == AccountType.Trade);
}

return result.AsExchangeResult<IEnumerable<SharedBalance>>(Exchange, TradingMode.Spot, data.Select(x => new SharedBalance(x.Asset, x.Available, x.Available + x.Holds)).ToArray());
}
Expand Down

0 comments on commit 99f4a07

Please sign in to comment.