public async Task WritesAStreamAsync() { const string testoutputfilename = "test"; string dir = Config.GetDefaultDownloadDirectory(); var files = new DirectoryInfo(dir).GetFiles().Where(n => n.Name == testoutputfilename + ".zip"); var fileInfos = files as IList<FileInfo> ?? files.ToList(); if (fileInfos.Any()) { foreach (var file in fileInfos) { File.Delete(file.FullName); } } FileInfo spyfile = new FileInfo(dir + @"\SPY_Companies.csv"); AllDataDownloader dl = new AllDataDownloader(spyfile, null) { ZipOutput = true }; await dl.WriteStreamAsync(DateTime.Now, "Test Data", dir, testoutputfilename); files = new DirectoryInfo(dir).GetFiles().Where(n => n.Name == testoutputfilename + ".zip"); Assert.IsTrue(files.Any()); }
public async Task GetsCsvSpyFromGoogleFinance() { const string testInputfilename = @"\SPY_Companies.csv"; string dir = Config.GetDefaultDownloadDirectory(); FileInfo spyfile = new FileInfo(dir + testInputfilename); AllDataDownloader dl = new AllDataDownloader(spyfile, null) { ZipOutput = false, OutputDirectory = dir }; await dl.DownloadDataFromListAsync(); DirectoryInfo di = new DirectoryInfo(dir + @"\daily\"); var files = di.GetFiles().Where(n => n.Name.Contains("csv")); int count = files.Count(); Assert.IsTrue(count > 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); } } }
// From nasdaq <a href="companies-by-industry.aspx?exchange=NYSE&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"); } } } }
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; } }
public async Task ProcessesAamcWithPriceOver1000Dollars() { const string testInputfilename = @"\AAMC_Companies.csv"; string dir = Config.GetDefaultDownloadDirectory(); FileInfo spyfile = new FileInfo(dir + testInputfilename); DirectoryInfo di = new DirectoryInfo(dir + @"\daily\"); AllDataDownloader dl = new AllDataDownloader(spyfile, null) { ZipOutput = true, OutputDirectory = dir }; await dl.DownloadDataFromListAsync(); var files = di.GetFiles().Where(n => n.Name.Contains("zip")); int count = files.Count(); Assert.IsTrue(count > 0); }
public async Task DataForAamrq() { FileInfo aamqrFileInfo = new FileInfo(@"I:\Dropbox\JJ\badsymbols.csv"); AllDataDownloader dl = new AllDataDownloader(aamqrFileInfo.FullName, null) { ZipOutput = true, OutputDirectory = aamqrFileInfo.DirectoryName + @"\data\" }; dl.SymbolList = aamqrFileInfo.FullName; // // Puts it in I:\Dropbox\JJ\equity\daily instead of I:\Dropbox\JJ\data\equity\daily // await dl.DownloadDataFromListAsync(); var files = new DirectoryInfo(dl.OutputDirectory).GetFiles("aamrq.*", SearchOption.AllDirectories); int count = files.Count(); Assert.IsTrue(count > 0); }