예제 #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 TestDictionaryConstructor()
        {
            StockState ss = new StockState();

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

            StockComparer sc = new StockComparer(allStocks);
        }
예제 #3
0
        public void TestRankOfBestStocks()
        {
            StockState ss = new StockState();

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

            //StockComparer sc = new StockComparer(allStocks);
            List <Stock> rank = StockComparer.RankOfBestStocks(allStocks);
        }
예제 #4
0
        public void TestRankStocksByCompare()
        {
            StockState ss = new StockState();

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

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

            StockComparer sc = new StockComparer(tradedEveryDay);

            sc.RankStocksByCompare();
        }
예제 #5
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");
        }
예제 #6
0
        public void TestEmailNotifier()
        {
            //the contents of the email
            StockState ss = new StockState();
            Dictionary <string, Stock> rankDic = ss.Deserialize("rankedStocks.bin");

            EmailNotifier en = new EmailNotifier("*****@*****.**", "33914047");

            StringBuilder sb = new StringBuilder();
            int           i  = 1;

            foreach (KeyValuePair <string, Stock> s in rankDic)
            {
                sb.Append(i + ". " + s.Value.stockCode + "\n");
                i++;
            }

            en.Send("StockMarket Rank", sb.ToString());
        }