Ejemplo n.º 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");
        }
Ejemplo n.º 2
0
        private async Task EnqueueData(string delta)
        {
            HistDataResponse histData = await BtrexREST.GetMarketHistoryV2(delta);

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

            DataQueue.Enqueue(histData);
        }