Esempio n. 1
0
        public static void GetKrakenMarketData()
        {
            WebClient   client     = new WebClient();
            KrakenQuote krakenInfo = new KrakenQuote();

            try
            {
                // GETTING QUOTES
                string webresponse = client.DownloadString("https://api.kraken.com/0/public/Ticker?pair=XBTEUR");

                JObject tmp = JObject.Parse(webresponse);

                krakenInfo.ask            = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["a"][0]);
                krakenInfo.bid            = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["b"][0]);
                krakenInfo.last           = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["c"][0]);
                krakenInfo.volume         = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["c"][1]);
                krakenInfo.volumetoday    = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["v"][0]);
                krakenInfo.volumeavgprice = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["p"][0]);
                krakenInfo.numoftrades    = Convert.ToDouble(tmp["result"]["XXBTZEUR"]["t"][0]);

                Console.WriteLine(string.Format("Ask:{0} | Bid:{1} | Last:{2} | VolumeToday:{3} | VolumeAVGPrice:{4} | NumOfTrades:{5} | Timestamp:{6}",
                                                krakenInfo.ask, krakenInfo.bid, krakenInfo.last, krakenInfo.volume, krakenInfo.volumetoday, krakenInfo.volumeavgprice, krakenInfo.numoftrades, DateTime.Now));

                KrakenData.InsertQuoteData(krakenInfo.ask, krakenInfo.bid, krakenInfo.last, krakenInfo.volume, krakenInfo.volumetoday, krakenInfo.volumeavgprice, krakenInfo.numoftrades, DateTime.Now);
            }

            catch (Exception ex)
            {
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //Delete all existing data in DBs

            KrakenData.RemoveQuoteData();
            KrakenData.RemoveIndicatorsData();
            KrakenData.RemoveAlarmsData();
            KrakenData.RemoveOrdersData();

            while (true)
            {
                KrakenFunctions.GetKrakenMarketData();
                Thread.Sleep(3000);
            }
        }