/// <summary> /// Gets a cryptocurrency by its name and its network. /// If it is not supported by the platform, it will return null /// </summary> /// <param name="crypto"></param> /// <param name="network"></param> /// <returns></returns> public static Crypto GetBySymbolAndNetwork(CryptoCurrencies crypto, CryptoNetworks network = CryptoNetworks.Standard) { switch (crypto) { case CryptoCurrencies.BTC: return(new Crypto(crypto, network, Crypto.BTC.Precision)); case CryptoCurrencies.ETH: return(new Crypto(crypto, network, Crypto.ETH.Precision)); case CryptoCurrencies.LTC: return(new Crypto(crypto, network, Crypto.LTC.Precision)); case CryptoCurrencies.USDT: return(new Crypto(crypto, network, Crypto.USDT.Precision)); case CryptoCurrencies.XMR: return(new Crypto(crypto, network, Crypto.XMR.Precision)); case CryptoCurrencies.XRP: return(new Crypto(crypto, network, Crypto.XRP.Precision)); case CryptoCurrencies.PGD: return(new Crypto(crypto, network, Crypto.PGD.Precision)); } return(null); }
public Crypto(CryptoCurrencies crypto, CryptoNetworks network, ushort precision, decimal howManyForOneUSD = decimal.MinValue) : base(howManyForOneUSD) { base.CurrencyId = (Currencies)crypto; this.CryptoCurrencyId = crypto; this.Network = network; this.Precision = precision; }
static void Main(string[] args) { Console.WriteLine("Enter password1:"); var password1 = Console.ReadLine(); Console.WriteLine("Enter password2:"); var password2 = Console.ReadLine(); var keyStore = new MongoAtlasStore(); keyStore.LogIn(password1.Trim(), password2.Trim()); keyStore.GetApiKeys(); var cmcConn = new CMCConnection(new System.Net.Http.HttpClient()); var quotesTask = CryptoCurrencysRequest.GetQuotes(cmcConn, keyStore.CoinMarketCapApiKey, "BTC,ETH,EOS,USDT,BNB,ADA,MKR,USDC,TUSD,REP,PAX,DAI"); quotesTask.Wait(); var quote = quotesTask.Result; var cryptoQuote = CryptoCurrencies.FromJson(quote); decimal ethUsd = 0.00M; if (cryptoQuote.Data.ContainsKey("ETH")) { Datum data = null; if (cryptoQuote.Data.TryGetValue("ETH", out data)) { ethUsd = (decimal)data.Quote.Usd.Price; } } decimal btcUsd = 0.00M; if (cryptoQuote.Data.ContainsKey("BTC")) { Datum data = null; if (cryptoQuote.Data.TryGetValue("BTC", out data)) { btcUsd = (decimal)data.Quote.Usd.Price; } } StringBuilder quotes = new StringBuilder(); foreach (var data in cryptoQuote.Data) { quotes.Append($"{data.Key} = ${data.Value.Quote.Usd.Price}\n"); } Console.WriteLine(quotes); #region BTC //var btcAddrStr = File.ReadAllText(@"c:\Apps\Test\btc.txt").Trim(); //var btcAddresses = btcAddrStr.Split('|'); //IBlockchain btcBC = new BitcoinBlockchain(); //foreach (var btcAddress in btcAddresses) //{ // if (!string.IsNullOrEmpty(btcAddress.Trim())) // { // var addr = btcAddress.Split(','); // var balTask = btcBC.GetBalance(addr[0]); // balTask.Wait(); // Console.WriteLine($"{addr[1]} Balance = BTC:{balTask.Result}, ${balTask.Result * btcUsd}\n"); // } //} #endregion #region ETH //var addressStr = File.ReadAllText(@"c:\Apps\Test\eth.txt").Trim(); //var addresses = addressStr.Split('|'); //IBlockchain ethBC = new EtheriumBlockchain(); //foreach (var address in addresses) //{ // if (!string.IsNullOrEmpty(address.Trim())) // { // var addr = address.Split(','); // var balTask = ethBC.GetBalance(addr[0]); // balTask.Wait(); // Console.WriteLine($"{addr[1]} Balance = ETH:{balTask.Result}, ${balTask.Result * ethUsd}\n"); // } //} #endregion Console.ReadLine(); }