Esempio n. 1
0
        public void TestMethodStocks()
        {
            var url = Stocks.MakeUrl("MSFT",
                                     new DateTime(2000, 9, 15),
                                     new DateTime(2000, 10, 18)
                                     );
            var res = Stocks.GetResult(url);

            var closerate = Stocks.DateMaxClose(res);

            Assert.IsTrue(closerate.Item2 > 20);
        }
Esempio n. 2
0
        public IEnumerable <Stocks.StockQuote> FetchStockData(string quote, string from, string to)
        {
            var fromdate = DateTime.ParseExact(from, "yyyyMMdd", CultureInfo.InvariantCulture);
            var todate   = DateTime.ParseExact(to, "yyyyMMdd", CultureInfo.InvariantCulture);

            Contract.Assert(fromdate <= todate, "Fromdate must be before todate");
            Contract.Assert(todate <= DateTime.Now, "Future not allowed yet...");

            var uri = Stocks.MakeUrl(quote, fromdate, todate);

            try {
                return(Stocks.GetResult(uri));
            }catch (System.Net.WebException) {
                //throw;
                return(Enumerable.Repeat(new Stocks.StockQuote(todate, -1.0), 1));
            }
        }