/// <summary> /// Lookup CoinMarketCap data using miner's preferred fiat currency /// </summary> public void InitCoinMarketCap() { try { // Exit if no fiat currency is selected if (Application.Current.Properties["Currency"] == null) { return; } // Exit if select worker is not currently mining if (MinerMonitorStat == null || MinerMonitorStat.CoinType == CoinType.UNDEFINED) { return; } string fiatCurrencyISOSymbol = Application.Current.Properties["Currency"].ToString(); // Attempt to get crypto coin name CoinNames.CoinNameDictionary.TryGetValue(MinerMonitorStat.CoinType, out string cryptoCurrencyName); // Load CoinMarketCap data CoinMarketCapAPI coinMarketCapAPI = new CoinMarketCapAPI(); CoinMarketCapResponse = coinMarketCapAPI.GetCoinMarketCapResponse(cryptoCurrencyName, fiatCurrencyISOSymbol); OnPropertyChanged("CoinMarketCapResponse"); } catch (Exception e) { ShowError(string.Format("Error loading coin market cap data: {0}", e.Message)); } }
/// <summary> /// Before using this controller, call Start(). /// </summary> public CrypnosticController( CrypnosticConfig config) { log.Trace(nameof(CrypnosticController)); Debug.Assert(config != null); Debug.Assert(config.supportedExchangeList.Length > 0); //Debug.Assert(instance == null); // won't be true if you stop then start. instance = this; coinMarketCap = new CoinMarketCapAPI(); foreach (KeyValuePair <string, string> aliasToName in config.coinAliasToName) { AddCoinAlias(aliasToName.Value, aliasToName.Key); } foreach (string blacklistedCoin in config.blacklistedCoins) { Debug.Assert(fullNameLowerToCoin.ContainsKey(blacklistedCoin.ToLowerInvariant()) == false); blacklistedFullNameLowerList.Add(blacklistedCoin.ToLowerInvariant()); } exchangeList = new Exchange[config.supportedExchangeList.Length]; for (int i = 0; i < config.supportedExchangeList.Length; i++) { ExchangeName name = config.supportedExchangeList[i]; Exchange exchange = Exchange.LoadExchange(name); exchangeList[i] = exchange; } }
/// <summary> /// Get CoinMarketCap info for conversion using specified fiat currency for worker /// </summary> /// <param name="coinType"></param> private CoinMarketCapResponse GetCoinMarketCapData(CoinType coinType) { try { // Exit if no fiat currency is selected if (Application.Current.Properties["Currency"] == null) { return(new CoinMarketCapResponse()); } string fiatCurrencyISOSymbol = Application.Current.Properties["Currency"].ToString(); // Attempt to get crypto coin name CoinNames.CoinNameDictionary.TryGetValue(coinType, out string cryptoCurrencyName); // Load CoinMarketCap data CoinMarketCapAPI coinMarketCapAPI = new CoinMarketCapAPI(); CoinMarketCapResponse coinMarketCapResponse = coinMarketCapAPI.GetCoinMarketCapResponse(cryptoCurrencyName, fiatCurrencyISOSymbol); return(coinMarketCapResponse); } catch (Exception e) { ShowError(string.Format("Error retrieving coin market cap data: {0}", e.Message)); return(new CoinMarketCapResponse()); } }
public void TestCMCCurrencyTokenPrices() { var lApiCMCInstance = new CoinMarketCapAPI(); var lSupportedFiat = lApiCMCInstance.GetTokenPrices(new string[] { "0x11d1d1d" }).Result; }
public void TestCMCMappedCoins() { IPriceSourceAPI lApiCMCInstance = new CoinMarketCapAPI(); var lSupportedCoins = lApiCMCInstance.GetPrices(new string[] { "biTCOIN" }).Result; }