Skip to content

Commit aab2fc0

Browse files
authored
fix OKEx OnGetAmountsAsync (#706)
For some reason Okex returns some small available balances with missing currency names, so we remove those.
1 parent 5946a82 commit aab2fc0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/ExchangeSharp/API/Exchanges/OKGroup/ExchangeOKExAPI.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAsync()
232232
var token = await GetBalance();
233233
return token[0]["details"]
234234
.Select(x => new { Currency = x["ccy"].Value<string>(), TotalBalance = x["cashBal"].Value<decimal>() })
235+
.Where(x => !string.IsNullOrEmpty(x.Currency))
235236
.ToDictionary(k => k.Currency, v => v.TotalBalance);
236237
}
237238

@@ -241,6 +242,7 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAvailable
241242
return token[0]["details"]
242243
.Select(x => new
243244
{ Currency = x["ccy"].Value<string>(), AvailableBalance = x["availBal"].Value<decimal>() })
245+
.Where(x => !string.IsNullOrEmpty(x.Currency))
244246
.ToDictionary(k => k.Currency, v => v.AvailableBalance);
245247
}
246248

@@ -254,6 +256,7 @@ protected override async Task<Dictionary<string, decimal>> OnGetMarginAmountsAva
254256
Currency = x["ccy"].Value<string>(),
255257
AvailableEquity = x["availEq"].Value<string>() == string.Empty ? 0 : x["availEq"].Value<decimal>()
256258
})
259+
.Where(x => !string.IsNullOrEmpty(x.Currency))
257260
.ToDictionary(k => k.Currency, v => v.AvailableEquity);
258261

259262
return includeZeroBalances

0 commit comments

Comments
 (0)