Skip to content

Commit

Permalink
Fix HitBTC again
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Aug 20, 2020
1 parent 4489655 commit a249a16
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions BTCPayServer.Rating/Providers/HitBTCRateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ public async Task<PairRate[]> GetRatesAsync(CancellationToken cancellationToken)
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);
Expand Down

0 comments on commit a249a16

Please sign in to comment.