public async Task <MarketPrice> GetPriceAsync(string shortName) { var marketPrice = new MarketPrice() { MarketName = "Coinexchangeio", CoinShortName = shortName }; try { if (root == null) { root = await HttpHelper.GetAsync <CoinexchangeioMarketRoot>($"https://www.coinexchange.io/api/v1/getmarkets"); } if (root.success == "1") { var findMarket = root.result.FirstOrDefault(f => f.MarketAssetCode.Equals($"{shortName.ToUpper()}") && f.BaseCurrencyCode == "BTC"); if (findMarket != null) { var find = await HttpHelper.GetAsync <CoinexchangeioMarketSummaryRoot>($"https://www.coinexchange.io/api/v1/getmarketsummary?market_id={findMarket.MarketID}"); if (find != null && find.success == "1" && find.result != null) { marketPrice.Price = find.result.BidPrice; marketPrice.Volume = find.result.Volume; marketPrice.IsGetPrice = true; } } } } catch (Exception e) { marketPrice.IsGetPrice = false; } return(marketPrice); }
public void Refresh() { root = null; }