Esempio n. 1
0
        public IEnumerable<CoinInformation> GetCoinInformation(string userAgent = "")
        {
            ApiWebClient client = new ApiWebClient();
            if (!string.IsNullOrEmpty(userAgent))
                client.Headers.Add("user-agent", userAgent);

            string apiUrl = GetApiUrl();

            string jsonString = client.DownloadFlakyString(apiUrl);

            JArray jsonArray = JArray.Parse(jsonString);

            List<CoinInformation> result = new List<CoinInformation>();

            foreach (JToken jToken in jsonArray)
            {
                CoinInformation coinInformation = new CoinInformation();
                coinInformation.PopulateFromJson(jToken);
                if (coinInformation.Difficulty > 0)
                    //only add coins with valid info since the user may be basing
                    //strategies on Difficulty
                    result.Add(coinInformation);
            }

            return result;
        }
Esempio n. 2
0
        public IEnumerable<ExchangeInformation> GetExchangeInformation()
        {
            ApiWebClient webClient = new ApiWebClient();

            string response = webClient.DownloadFlakyString(new Uri(GetApiUrl()));

            Data.SellPrices sellPrices = JsonConvert.DeserializeObject<Data.SellPrices>(response);

            List<ExchangeInformation> results = new List<ExchangeInformation>();

            results.Add(new ExchangeInformation()
            {
                SourceCurrency = "BTC",
                TargetCurrency = "USD",
                TargetSymbol = "$",
                ExchangeRate = sellPrices.Subtotal.Amount
            });

            return results;
        }
Esempio n. 3
0
        public IEnumerable<ExchangeInformation> GetExchangeInformation()
        {
            ApiWebClient webClient = new ApiWebClient();
            webClient.Encoding = Encoding.UTF8;

            string response = webClient.DownloadFlakyString(new Uri(GetApiUrl()));

            Dictionary<string, TickerEntry> tickerEntries = JsonConvert.DeserializeObject<Dictionary<string, TickerEntry>>(response);

            List<ExchangeInformation> results = new List<ExchangeInformation>();

            foreach (KeyValuePair<string, TickerEntry> keyValuePair in tickerEntries)
            {
                results.Add(new ExchangeInformation()
                {
                    SourceCurrency = "BTC",
                    TargetCurrency = keyValuePair.Key,
                    TargetSymbol = keyValuePair.Value.Symbol,
                    ExchangeRate = keyValuePair.Value.Last
                });
            }

            return results;
        }