//Step 1: Analyze stock performance public static void PerformFullAnalysis() { Console.Write("Path of folder containing S&P500 equity transactions (or single file): "); string path1 = Console.ReadLine(); Console.Write("Path of full analysis export: "); string path2 = Console.ReadLine(); //Clean paths path1 = path1.Replace("\"", ""); path2 = path2.Replace("\"", ""); //Get the files string[] files = null; if (System.IO.Directory.Exists(path1)) { files = System.IO.Directory.GetFiles(path1); } else if (System.IO.File.Exists(path1)) { files = new string[] { path1 }; } //Process each int FileCounter = 1; foreach (string s in files) { string file_name = System.IO.Path.GetFileName(s); AdminPrint("Checking #" + FileCounter.ToString() + "/" + files.Length.ToString() + ": " + file_name + "..."); if (System.IO.File.Exists(path2 + "\\" + file_name) == false) { AdminPrint("This has not been research yet. Going!"); //Reseaerch bool ResearchFailed = false; FullResearchSet frs = new FullResearchSet(); frs.StatusPrintingOn(); try { frs.GenerateFromTransactionsFileAsync(s).Wait(); } catch (Exception ex) { AdminPrint("Generation for " + file_name + " failed. Msg: " + ex.Message, ConsoleColor.Red); ResearchFailed = true; } //Write it (if it has analyses) if (frs.PerformancesFollowingInsiderBuys != null) { if (frs.PerformancesFollowingInsiderBuys.Length > 0) { if (ResearchFailed == false) { AdminPrint("Writing to file..."); System.IO.File.WriteAllText(path2 + "\\" + file_name, JsonConvert.SerializeObject(frs)); AdminPrint("Successfully written!"); } } else { AdminPrint("Not going to write this one to file... It had no performance analyses following transctions!", ConsoleColor.Yellow); } } } else { AdminPrint("This has already been researched. skipping."); } FileCounter = FileCounter + 1; } }