/// <summary> /// USD per Coin /// </summary> /// <param name="fiatCoin">Fiat coin</param> /// <param name="date">Date</param> public static decimal UsdPerCoin(ECoin fiatCoin, DateTime date) { var down = DownloadHelper.Download <FiatResult>($"https://api.exchangeratesapi.io/{date.ToString("yyyy-MM-dd")}?base=USD", true); if (down != null && down.Rates.TryGetValue(fiatCoin.ToString(), out var value)) { return(value); } throw new ArgumentException(); }
/// <summary> /// Get coin /// </summary> /// <param name="coin">Coin</param> /// <returns>Coin</returns> private string GetCoin(ECoin coin) { switch (coin) { case ECoin.EUR: case ECoin.USD: case ECoin.USDT: case ECoin.BNB: case ECoin.BTC: case ECoin.ETH: return(coin.ToString()); } throw new ArgumentException(nameof(coin)); }
/// <summary> /// Get coin id /// </summary> /// <param name="coin">Coin</param> /// <returns>Return id</returns> private string GetCoinId(ECoin coin) { switch (coin) { case ECoin.BTC: case ECoin.ETH: case ECoin.BNB: case ECoin.USDT: { if (!_coinCache.TryGetValue(coin.ToString(), out var value)) { throw new ArgumentException(nameof(coin)); } return(value); } default: throw new ArgumentException(nameof(coin)); } }