public async static Task <CoinDetails> GetCoinTicker(string id) { CoinDetails Coin = null; var Client = CoinMarketCapClient.GetInstance(); var Ticker = await Client.GetTickerAsync(id); Coin = new CoinDetails() { AvailableSupply = Ticker.AvailableSupply, Id = Ticker.Id, Name = Ticker.Name, PercentChange1h = Ticker.PercentChange1h, PercentChange24h = Ticker.PercentChange24h, PercentChange7d = Ticker.PercentChange7d, PriceBtc = Ticker.PriceBtc, Rank = Ticker.Rank, Symbol = Ticker.Symbol, TotalSupply = Ticker.TotalSupply, LastUpdatedUnixTime = Ticker.LastUpdatedUnixTime, LastUpdated = Ticker.LastUpdated, MarketCapUsd = Ticker.MarketCapUsd, MarketCapOther = Ticker.MarketCapOther.ToEntity(), PriceOther = Ticker.PriceOther.ToEntity(), PriceUsd = Ticker.PriceUsd, Volume24hOther = Ticker.Volume24hOther.ToEntity(), Volume24hUsd = Ticker.Volume24hUsd }; return(Coin); }
public int GetHashCode(CoinDetails obj) { unchecked { return(obj.FirstItem); } }
private static CoinDetails Map(CoinDetails x) { if (x == null) { return(null); } var c = new CoinDetails { Id = x.Id, Name = x.Name, Symbol = x.Symbol, Platforms = x.Platforms.ContainsKey("") ? null : x.Platforms }; if (x.Market_data?.Current_price == null) { return(c); } c.Market_data = new MarketData { Current_price = x.Market_data.Current_price.ContainsKey("") ? null : x.Market_data.Current_price }; return(c); }
public override bool Equals(object obj) { CoinDetails c2 = obj as CoinDetails; if (c2 == null) { return(false); } return(Denomination == c2.Denomination && Design == c2.Design); }
public async static Task <List <CoinDetails> > GetTicker() { var Coins = new List <CoinDetails>(); var Client = CoinMarketCapClient.GetInstance(); var TickerList = await Client.GetTickerListAsync(1000); TickerList.Reverse(); try { var Tasks = new List <Task <KeyValuePair <long, decimal> > >(); foreach (var Ticker in TickerList) { int?daysOld = null; double?Vol = 0; try { Vol = Ticker.Volume24hUsd.GetValueOrDefault(); } catch { } try { daysOld = GetCoinAgeInDays(Ticker.Symbol, Ticker.Id); } catch (Exception ex) { var E = ex; Debug.WriteLine(ex.Message); if (ex.InnerException != null) { Debug.WriteLine(ex.InnerException.Message); } } var Info = new CoinDetails() { AvailableSupply = Ticker.AvailableSupply.GetValueOrDefault(), Id = Ticker.Id, Name = Ticker.Name, PercentChange1h = Ticker.PercentChange1h.GetValueOrDefault(), PercentChange24h = Ticker.PercentChange24h.GetValueOrDefault(), PercentChange7d = Ticker.PercentChange7d.GetValueOrDefault(), PriceBtc = Ticker.PriceBtc, Rank = Ticker.Rank, Symbol = Ticker.Symbol, TotalSupply = Ticker.TotalSupply.GetValueOrDefault(), LastUpdatedUnixTime = Ticker.LastUpdatedUnixTime, LastUpdated = Ticker.LastUpdated, MarketCapUsd = Ticker.MarketCapUsd.GetValueOrDefault(), MarketCapOther = Ticker.MarketCapOther.ToEntity(), PriceOther = Ticker.PriceOther.ToEntity(), PriceUsd = Ticker.PriceUsd, Volume24hOther = Ticker.Volume24hOther.ToEntity(), Volume24hUsd = Vol, DaysOld = daysOld }; Tasks.Add(GetATH(Ticker.Id)); Coins.Add(Info); } var Completed = await Task.WhenAll(Tasks); for (var i = 0; i < Completed.Length; i++) { var ATH = Completed[i]; Coins[i].ATH = (float)ATH.Value; Coins[i].LastATH = FromUnixTime(ATH.Key); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); if (ex.InnerException != null) { Debug.WriteLine(ex.InnerException.Message); } } return(Coins); }