Beispiel #1
0
        // ###############################################################################################
        //  (GET) Historic prices
        internal async static Task GetHisto(string crypto, string time, int limit)
        {
            if (crypto == "MIOTA")
            {
                crypto = "IOT";
            }

            //CCCAGG Bitstamp Bitfinex Coinbase HitBTC Kraken Poloniex
            string URL = "https://min-api.cryptocompare.com/data/histo" + time + "?e=CCCAGG&fsym="
                         + crypto + "&tsym=" + coin + "&limit=" + limit;

            if (limit == 0)
            {
                URL = "https://min-api.cryptocompare.com/data/histoday?e=CCCAGG&fsym=" + crypto + "&tsym=" + coin + "&allData=true";
            }

            Uri        uri        = new Uri(URL);
            HttpClient httpClient = new HttpClient();

            try {
                string response = await httpClient.GetStringAsync(uri);

                var data = JToken.Parse(response);

                App.historic.Clear();
                App.historic = JSONhistoric.HandleHistoricJSON(data);
            } catch (Exception) {
                App.historic.Clear();
                App.historic = JSONhistoric.HandleHistoricJSONnull(limit);
                //var dontWait = await new MessageDialog(ex.Message).ShowAsync();
            }
            finally{
                httpClient.Dispose();
            }
        }
Beispiel #2
0
        internal async static Task <List <JSONhistoric> > GetHistoricalPrices(string crypto, string timeSpan)
        {
            if (crypto == "MIOTA")
            {
                crypto = "IOT";
            }

            var tuple = ParseTimeSpan(timeSpan);

            timeSpan = tuple.Item1;
            int limit = tuple.Item2;

            //CCCAGG Bitstamp Bitfinex Coinbase HitBTC Kraken Poloniex
            string URL = "https://min-api.cryptocompare.com/data/histo" + timeSpan + "?e=CCCAGG&fsym="
                         + crypto + "&tsym=" + coin + "&limit=" + limit;

            if (limit == 0)
            {
                URL = "https://min-api.cryptocompare.com/data/histoday?e=CCCAGG&fsym=" + crypto + "&tsym=" + coin + "&allData=true";
            }

            Uri        uri        = new Uri(URL);
            HttpClient httpClient = new HttpClient();

            try {
                string response = await httpClient.GetStringAsync(uri);

                var data = JToken.Parse(response);

                return(JSONhistoric.HandleHistoricJSON(data));
            }
            catch (Exception) {
                return(JSONhistoric.HandleHistoricJSONnull(limit));
            }
            finally {
                httpClient.Dispose();
            }
        }