コード例 #1
0
ファイル: Program.cs プロジェクト: WhoStoleMyToast/StockBuddy
        private static void UpdateRatings(IEnumerable <string> symbols)
        {
            var dateTimeStamp = DateTime.Now;

            IList <Stock> stocks = new List <Stock>();

            IStockService _stockService = new StockService();

            //var symbols = new List<string>() { "aame", "dis"};
            foreach (var symbol in symbols.Select((value, index) => new { index, value }))
            {
                //System.Console.Write("\r{0} Remaining", symbols.Count - symbol.index);
                decimal?rating = _yahooDataProvider.GetStockRating(symbol.value);

                if (rating != null)
                {
                    stocks.Add(new Stock {
                        ModifiedDate = dateTimeStamp, Symbol = symbol.value, Rating = rating.Value
                    });

                    //System.Console.WriteLine("{0}: {1}", symbol.value, rating.Value);
                }

                Thread.Sleep(1000);
            }

            _stockService.AddOrUpdateStocks(stocks);
            _stockService.Dispose();
        }