public async Task GetsSpyCsvFromGoogleFinance()
        {
            GetDefaults();
            DirectoryInfo di = new DirectoryInfo(_spyfile.DirectoryName + @"\NYSEARCA\S\SPY\");

            if (di.Exists)
            {
                foreach (var file in di.EnumerateFiles())
                {
                    file.Delete();
                }
            }

            MinuteDownloader dl = new MinuteDownloader(_spyfile, null)
            {
                FormatAsMilliseconds = true,
                SplitDays            = true,
                ZipOutput            = false,
                OutputDirectory      = _dir
            };
            await dl.DownloadDataFromListAsync();

            var files = di.GetFiles().Where(n => n.Name.Contains("csv"));
            int count = files.Count();

            Assert.IsTrue(count > 0);
        }
Exemple #2
0
        private async Task GetMinuteAndDailyData()
        {
            Cursor currentCursor = Cursor.Current;

            currentCursor = Cursors.WaitCursor;

            var destinationDirectory = Config.GetDefaultDownloadDirectory();
            var defaultInputFile     = Config.GetDefaultInputFile();

            string[] validatedArgs = new string[3];
            validatedArgs[0]     = defaultInputFile;
            validatedArgs[1]     = destinationDirectory;
            richTextBoxData.Text = "Processing Files ...\n";
            richTextBoxData.Refresh();
            validatedArgs[2] = "minute";
            Logger logger = new Logger("errors.txt");

            try
            {
                FileInfo         tickerListInfo   = new FileInfo(validatedArgs[0]);
                string           directory        = validatedArgs[1];
                MinuteDownloader minuteDownloader = new MinuteDownloader(tickerListInfo, directory)
                {
                    FormatAsMilliseconds = true,
                    SplitDays            = true,
                    ZipOutput            = true,
                    logger = new Logger("MinuteLog.txt")
                };
                await minuteDownloader.DownloadDataFromListAsync();

                tickerListInfo = new FileInfo(validatedArgs[0]);
                directory      = validatedArgs[1];

                AllDataDownloader downloader = new AllDataDownloader(tickerListInfo, directory)
                {
                    ZipOutput = true,
                    logger    = new Logger("DailyLogger.txt")
                };
                await downloader.DownloadDataFromListAsync();

                CopyFiles();
                string        message = string.Format(@"JJ,\nI updated the Dropbox minute and daily data.  \nThe process completed at {0}\n Files were copied.\n\nNick\n\nThis message was auto generated by the MarketData program.  Do not reply to the sending address.", DateTime.Now.ToLongDateString());
                Notifications n       = new Notifications();
                if (n.CustomEmail("*****@*****.**", "Dropbox files have been updated", message))
                {
                    richTextBoxData.Text += "Email Sent\n";
                }
            }
            catch (Exception ex)
            {
                logger.Log(ex.Message + ex.StackTrace);
            }
            finally
            {
                Cursor.Current = currentCursor;
            }
        }
Exemple #3
0
        /// <summary>
        /// The async portion of the app
        /// </summary>
        /// <param name="args">string[] - a validated copy of the command line args</param>
        /// <returns>nothing</returns>
        private static async Task MainAsync(string[] args)
        {
            Logger logger = new Logger("errors.txt");

            if (args[2] == "minute")
            {
                try
                {
                    FileInfo tickerListInfo = new FileInfo(args[0]);
                    string   directory      = args[1];

                    MinuteDownloader minuteDownloader = new MinuteDownloader(tickerListInfo, directory)
                    {
                        FormatAsMilliseconds = true,
                        SplitDays            = true,
                        ZipOutput            = true
                    };
                    minuteDownloader.logger = new Logger("MinuteLog.txt");
                    await minuteDownloader.DownloadDataFromListAsync();
                }
                catch (Exception e)
                {
                    logger.Log(e.Message + e.StackTrace);
                }
            }
            if (args[2].ToLower() == "eod" || args[2].ToLower() == "daily")
            {
                try
                {
                    FileInfo tickerListInfo = new FileInfo(args[0]);
                    string   directory      = args[1];

                    AllDataDownloader downloader = new AllDataDownloader(tickerListInfo, directory)
                    {
                        ZipOutput = true
                    };
                    downloader.logger = new Logger("DailyLogger.txt");
                    await downloader.DownloadDataFromListAsync();
                }
                catch (Exception e)
                {
                    logger.Log(e.Message + e.StackTrace);
                }
            }
        }
        public async Task GetsSpyZipFromGoogleFinance()
        {
            GetDefaults();

            MinuteDownloader dl = new MinuteDownloader(_spyfile, null)
            {
                FormatAsMilliseconds = true,
                SplitDays            = true,
                ZipOutput            = true,
                OutputDirectory      = _dir
            };
            await dl.DownloadDataFromListAsync();

            DirectoryInfo di    = new DirectoryInfo(_dir + @"\NYSEARCA\S\SPY\");
            var           files = di.GetFiles().Where(n => n.Name.Contains("zip"));
            int           count = files.Count();

            Assert.IsTrue(count == 1);
        }
        public void ZipsAllCsvFiles()
        {
            GetDefaults();
            var basedir = new DirectoryInfo(_dir + @"\NYSEARCA\");

            MinuteDownloader dl = new MinuteDownloader();

            dl.FormatAsMilliseconds = true;
            dl.SplitDays            = true;
            dl.ZipOutput            = true;
            dl.FindAndZipCsvFiles(basedir);

            // For test purposes look for the SPY directory, the most commonly used symbol
            DirectoryInfo di = new DirectoryInfo(basedir + @"\S\SPY\");

            // count the files and make sure there are at least 2 zip files
            var files = di.GetFiles().Where(n => n.Name.Contains("zip"));
            int count = files.Count();

            Assert.IsTrue(count > 2);
        }
Exemple #6
0
        // From nasdaq  <a href="companies-by-industry.aspx?exchange=NYSE&amp;render=download" rel="nofollow"><b>Download this list</b></a>
        private async void buttonList_Click(object sender, EventArgs e)
        {
            string tickerListFilename = GetTickerListFilepath();

            if (tickerListFilename != string.Empty)
            {
                FileInfo tickerListInfo = new FileInfo(tickerListFilename);
                string   directory      = Config.GetDefaultDownloadDirectory();
                directory = GetSaveDirectory();
                if (directory.Length > 0)
                {
                    Cursor currentCursor = Cursor.Current;
                    currentCursor = Cursors.WaitCursor;
                    var caption = buttonList.Text;
                    // update ui
                    buttonList.Text           = @"Downloading";
                    buttonList.Enabled        = false;
                    checkBoxDateTime.Checked  = true;
                    checkBoxSplitDays.Checked = true;
                    checkBoxZipOutput.Checked = true;

                    try
                    {
                        if (radioButtonMinutes.Checked)
                        {
                            // Save the data to zip files
                            MinuteDownloader minuteDownloader = new MinuteDownloader(tickerListInfo, directory)
                            {
                                FormatAsMilliseconds = true,
                                SplitDays            = true,
                                ZipOutput            = true,
                                OutputDirectory      = directory
                            };
                            minuteDownloader.logger = new Logger("MinuteLog.txt");
                            await minuteDownloader.DownloadDataFromListAsync();
                        }
                        if (radioButtonAllData.Checked)
                        {
                            AllDataDownloader allDataDownloader = new AllDataDownloader(tickerListInfo, directory)
                            {
                                ZipOutput       = true,
                                OutputDirectory = directory
                            };
                            allDataDownloader.logger = new Logger("DailyLog.txt");
                            await allDataDownloader.DownloadDataFromListAsync();
                        }
                    }
                    catch (Exception exc)
                    {
                        ErrorFunction(exc.Message, exc);
                    }
                    finally
                    {
                        Cursor.Current     = currentCursor;
                        buttonList.Enabled = true;
                        buttonList.Text    = caption;
                        MessageBox.Show(@"Done");
                    }
                }
            }
        }