예제 #1
0
        public async Task UpdateHistData()
        {
            Console.WriteLine();

            //Start ProcessQueue thread:
            var SQLthread = new Thread(() => ProcessDataQueue());

            SQLthread.IsBackground = true;
            SQLthread.Name         = "Saving-Market-Histories";
            SQLthread.Start();


            //Call list of available markets from Btrex:
            GetMarketsResponse markets = await BtrexREST.GetMarkets();

            if (markets.success != true)
            {
                Console.WriteLine("    !!!!ERR GET-MARKETS>>> " + markets.message);
                return;
            }


            //Create string list of BTC market deltas only:
            List <string> BTCmarketDeltas = new List <string>();

            foreach (GetMarketsResult market in markets.result)
            {
                if (market.MarketName.Split('-')[0] == "BTC")
                {
                    BTCmarketDeltas.Add(market.MarketName);
                }
            }

            totalCount = BTCmarketDeltas.Count;

            //Download all market histories, enqueue responses:
            var downloadHists = BTCmarketDeltas.Select(EnqueueData).ToArray();
            await Task.WhenAll(downloadHists);

            //Wait for save data process to complete, then end thread:
            while (!savedComplete)
            {
                Thread.Sleep(100);
            }

            SQLthread.Abort();
            Console.WriteLine();

            Console.WriteLine("Updating CSVs - Just a moment...");
            UpdateOrCreateCSVs();

            // Garbage Collection to force close SQLiteConnection, delete temp data:
            GC.Collect();
            GC.WaitForPendingFinalizers();
            File.Delete("MarketHistory.data");

            Console.WriteLine("DONE");
        }
예제 #2
0
        public static async Task <GetMarketsResponse> GetMarkets()
        {
            GetMarketsResponse  marketsResponse = null;
            HttpResponseMessage response        = await client.GetAsync("public/getmarkets");

            if (response.IsSuccessStatusCode)
            {
                marketsResponse = await response.Content.ReadAsAsync <GetMarketsResponse>();
            }
            return(marketsResponse);
        }