private void DownloadTimer(DownloadEngine download, Formatting formatting, PeregrineOperation peregrine, MACD macd, Stochastic stochastic,
                                   TechnicalIndicators indicators, Transactions transactions, WebClient web, WebURIs uRIs, string Database, string downloadTime)
        {
            var DailyTime = downloadTime;  //Time when method needs to be called

            var timeParts = DailyTime.Split(new char[1] {
                ':'
            });

            var dateNow = DateTime.Now;
            var date    = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day,
                                       int.Parse(timeParts[0]), int.Parse(timeParts[1]), int.Parse(timeParts[2]));
            TimeSpan ts;

            if (date > dateNow)
            {
                ts = date - dateNow;
            }
            else
            {
                date = date.AddDays(1);
                ts   = date - dateNow;
            }
            while (date != dateNow)
            {
                Console.WriteLine($"Waiting for {downloadTime}");
                //waits certan time and run the code
                Task.Delay(ts).ContinueWith((x) => Download(date, download, formatting, peregrine, macd, stochastic, indicators, transactions, web, uRIs, Database));
                Console.Read();
            }
        }
        public void Run(string downloadTime)
        {
            DateTime           date          = DateTime.Now;
            DownloadEngine     download      = new DownloadEngine();
            Formatting         formatting    = new Formatting();
            PeregrineOperation peregrine     = new PeregrineOperation();
            MACD                macd         = new MACD();
            Stochastic          stochastic   = new Stochastic();
            TechnicalIndicators indicators   = new TechnicalIndicators();
            Transactions        transactions = new Transactions();
            WebClient           web          = new WebClient(); // provides the ability to download from the internet
            WebURIs             uRIs         = new WebURIs();   // refers to an instance of the Wall Street Journal URL

            DownloadTimer(download, formatting, peregrine, macd, stochastic, indicators, transactions, web, uRIs, Database, downloadTime);
        }
        /// Download and save to Database
        private void Download(DateTime date, DownloadEngine download, Formatting formatting, PeregrineOperation peregrine, MACD macd, Stochastic stochastic, TechnicalIndicators indicators, Transactions transactions, WebClient web, WebURIs uRIs, string Database)
        {
            List <string> Symbols = transactions.DatabaseSymbolListQuery(Database, stocks);

            transactions.TruncateStockTable(Database, "Clean Data"); // clears data from the clean data table.
            int count = 1;

            foreach (var stock in Symbols)
            {
                Console.Clear();
                Console.WriteLine($"Downloading {stock} || {count} of {Symbols.Count}");
                download.ToDatabase(date, formatting, peregrine, transactions, web, uRIs, stock, Database);
                count++;
            }
            Console.WriteLine("I'm Done");
            //count = 1;
            //calls the list of stocks that have been data verified
            //List<string> CleanData = transactions.DatabaseSymbolListQuery(Database, stocks);
            //foreach (var stock in CleanData)
            //{
            //    Console.Clear();
            //    Console.WriteLine($"Doing Math {stock} || {count} of {CleanData.Count}");
            //    List<Results> results = MathPredictsTheFuture(download, macd, stochastic, transactions, indicators, stock);
            //    transactions.SaveToTableResult(Database, results); // saves the calculations to the Results table in the database
            //    count++;
            //}


            //// calls the stocks from the results list
            //List<PeregrineResults> todaysResults = transactions.DailyResultsQuery(peregrine.Database);
            //transactions.TruncateStockTable(database, peregrineresults); // clears the web results table. This table feeds the model for the ASP.Net interface.
            //transactions.SaveToTableWebResult(peregrine.Database, todaysResults);
            //Console.WriteLine("Peregrine Results Updated");
        }