Fix HitBTC again

This commit is contained in:
nicolas.dorier 2020-08-20 13:15:25 +09:00
parent 44896559c6
commit a249a164f7
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE

View File

@ -24,13 +24,21 @@ namespace BTCPayServer.Rating
var jarray = await response.Content.ReadAsAsync<JArray>(cancellationToken);
return jarray
.Children<JObject>()
.Where(p => CurrencyPair.TryParse(p["symbol"].Value<string>(), out _))
.Select(p => new PairRate(CurrencyPair.Parse(p["symbol"].Value<string>()), CreateBidAsk(p)))
.Select(p =>
{
CurrencyPair.TryParse(p["symbol"].Value<string>(), out var currency);
var bidask = CreateBidAsk(p);
return (currency, bidask);
})
.Where(p => p.currency != null && p.bidask != null)
.Select(p => new PairRate(p.currency, p.bidask))
.ToArray();
}
private BidAsk CreateBidAsk(JObject p)
{
if (p["bid"].Type != JTokenType.String || p["ask"].Type != JTokenType.String)
return null;
var bid = p["bid"].Value<decimal>();
var ask = p["ask"].Value<decimal>();
return new BidAsk(bid, ask);