예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Creating stock dictionary");
            Dictionary <string, Stock> stocks = new Dictionary <string, Stock>();

            Console.WriteLine("Checking to see if there is already an data analysis for today");
            if (File.Exists("stocksWithIndicators.bin") && new FileInfo("stocksWithIndicators.bin").CreationTime.Date == DateTime.Now.Date)
            {
                Console.WriteLine("There is. Recovering file");
                StockState ss = new StockState();
                stocks = ss.Deserialize("stocksWithIndicators.bin");
            }
            else
            {
                Console.WriteLine("There is not. Procceding with Analysis.");
                Console.WriteLine("Getting most recent stock market file");
                HistoryFileSelector hfs = new HistoryFileSelector(@"C:\Users\Cliente\Downloads");
                string mostRecent       = hfs.GetMostRecentFileFullPath();

                Console.WriteLine("Reading data from file");
                stocks = Reader.GetAllStockData(mostRecent);

                Console.WriteLine("Analyzing data");
                sw.Start();
                MarketHistoryAnalyzer.FillAllWithDefaults(stocks, PrintProgress);
                sw.Stop();

                Console.WriteLine("Saving to disk");
                StockState sc1 = new StockState(stocks);
                sc1.Serialize("stocksWithIndicators.bin");
            }



            Console.WriteLine("Removing stocks not traded every day");
            List <Stock> tradedEveryday = StockComparer.RemoveStocksNotTradedEveryday(stocks);

            Console.WriteLine("Creating Stock Comparator");
            StockComparer sc = new StockComparer(tradedEveryday);

            Console.WriteLine("Running comparison");
            //List<Stock> rankedStocks = StockComparer.RankOfBestStocks(tradedEveryday);
            sc.RankStocksByCompare();

            Console.WriteLine("Saving to disk");
            StockState sc2 = new StockState(sc.RankedStocks);

            sc2.Serialize("rankedStocks.bin");

            Console.WriteLine("Emailing results");
            EmailNotifier en = new EmailNotifier("ff12sender", "33914047");

            en.Send(sc.RankedStocks);

            Console.WriteLine("All done. Check your email");
            Console.WriteLine("Press any key to exit");

            Console.ReadKey();
        }
예제 #2
0
        public void TestSerialize()
        {
            ////CONTINUE HERE
            //string s = Properties.Resources.COTAHIST_A2016;
            //List<string> allLines = Reader.GetAllLinesFromPath("COTAHIST_A2016.TXT");
            //Dictionary<string, Stock> allStocks = Reader.GetAllStockData(allLines);

            StockState sc = new StockState(allStocks);

            sc.Serialize("stocks.bin");

            Assert.IsTrue(File.Exists("stocks.bin"));
        }
예제 #3
0
        public void TestRemoveStocksNotTradedEveryday()
        {
            StockState ss = new StockState();

            Dictionary <string, Stock> allStocks = ss.Deserialize("stocksWithIndicators.bin");

            List <Stock> dailyTradedStocks = StockComparer.RemoveStocksNotTradedEveryday(allStocks);

            //StockComparer sc = new StockComparer(allStocks);
            List <Stock> rank = StockComparer.RankOfBestStocks(dailyTradedStocks);

            StockState sc = new StockState(rank);

            sc.Serialize("rankedStocks.bin");
        }
예제 #4
0
        public bool RunAnalysis()
        {
            //UpdateLabel ul = new UpdateLabel(updateInfoLabel);

            updateInfoLabel("Creating stock dictionary");
            Dictionary <string, Stock> stocks = new Dictionary <string, Stock>();

            //string filePath = fileLocationTxtBox.Text;

            updateInfoLabel("Reading data from file");
            stocks = Reader.GetAllStockData(fileLocation);

            updateInfoLabel("Analyzing data");
            MarketHistoryAnalyzer.FillAllWithDefaults(stocks, SetProgress);

            updateInfoLabel("Saving to disk");
            StockState sc1 = new StockState(stocks);

            sc1.Serialize("stocksWithIndicators.bin");

            updateInfoLabel("Removing stocks not traded every day");
            List <Stock> tradedEveryday = StockComparer.RemoveStocksNotTradedEveryday(stocks);

            updateInfoLabel("Creating Stock Comparator");
            StockComparer sc = new StockComparer(tradedEveryday);

            updateInfoLabel("Running comparison");
            sc.RankStocksByCompare();

            updateInfoLabel("Saving to disk");
            StockState sc2 = new StockState(sc.RankedStocks);

            sc2.Serialize("rankedStocks.bin");

            updateInfoLabel("Emailing results");
            EmailNotifier en = new EmailNotifier("ff12sender", "33914047");

            en.Send(sc.RankedStocks);

            updateInfoLabel("All done. Check your email");

            return(true);
        }