static void Main(string[] args)
        {
            var quote_service = new QuoteService();
            var quotes = quote_service.Quote("MSFT", "GOOG").Return(QuoteReturnParameter.Symbol,
                                                                    QuoteReturnParameter.Name,
                                                                    QuoteReturnParameter.LatestTradePrice,
                                                                    QuoteReturnParameter.LatestTradeTime);

            foreach (var quote in quotes)
            {
                Console.WriteLine("{0} - {1} - {2} - {3}", quote.Symbol, quote.Name, quote.LatestTradePrice, quote.LatestTradeTime);
            }

            var google_quote = quote_service.Quote("DHI").Return(QuoteReturnParameter.Symbol,
                                                                  QuoteReturnParameter.Name,
                                                                  QuoteReturnParameter.LatestTradePrice,
                                                                  QuoteReturnParameter.LatestTradeTime);
            Console.WriteLine("{0} - {1} - {2} - {3}", google_quote[QuoteReturnParameter.Symbol],
                                                       google_quote[QuoteReturnParameter.Name],
                                                       google_quote[QuoteReturnParameter.LatestTradePrice],
                                                       google_quote[QuoteReturnParameter.LatestTradeTime]);
            Console.ReadLine();
            Console.WriteLine();

            Console.WriteLine("Daily historical prices for VTIAX");

            var historical_price_service = new HistoricalPriceService();
            foreach (var price in historical_price_service.Get("VTIAX", new DateTime(2014, 1, 1), DateTime.UtcNow, Period.Daily))
            {
                Console.WriteLine("{0} - {1} ", price.Date.ToString("MMM dd,yyyy"), price.Price);
            }

            Console.ReadLine();
        }
        public void HistoricalTest()
        {
            var service = new HistoricalPriceService();
            var endDate = DateTime.Today.AddDays(-1);
            var startDate = endDate.AddDays(-49);

            var prices = service.Get("GOOG", startDate, endDate, Period.Weekly).ToList();
        }
Esempio n. 3
0
 public static IEnumerable<HistoricalPrice> GetStockHistoricalPrices(string ticker, DateTime startDate, DateTime endDate)
 {
     HistoricalPriceService hps = new HistoricalPriceService();
     IEnumerable<HistoricalPrice> historicalPrices = null;
     try
     {
         historicalPrices = hps.Get(ticker, startDate, endDate, Period.Daily);
     }
     catch(Exception ex)
     {
         return null;
     }
     return historicalPrices;
 }
Esempio n. 4
0
 private static decimal GetCurrentStockPrice(HistoricalPriceService hps, string ticker, DateTime start, DateTime end)
 {
     IEnumerable<HistoricalPrice> price;
     decimal currentPrice; 
     DateTime mostRecentDate;
     try
     {
         price = hps.Get(ticker, start, end, Period.Daily);
         mostRecentDate = price.Select(p => p.Date).Max();
         currentPrice = price.Single(p => p.Date == mostRecentDate).Price;
         return currentPrice;
     }
     catch (Exception Ex)
     {
         return GetCurrentStockPrice(hps, ticker, start.AddDays(-1), end);
     }
 }
Esempio n. 5
0
 public static decimal GetCurrentStockPrice(string ticker)
 {
     HistoricalPriceService hps = new HistoricalPriceService();
     IEnumerable<HistoricalPrice> price;
     decimal currentPrice; 
     DateTime mostRecentDate;
     try
     {
         price = hps.Get(ticker, DateTime.Now, DateTime.Now, Period.Daily);
         mostRecentDate = price.Select(p => p.Date).Max();
         currentPrice = price.Single(p => p.Date == mostRecentDate).Price;
         return currentPrice;
     }
     catch (Exception ex)
     {
         return GetCurrentStockPrice(hps, ticker, DateTime.Now.AddDays(-1), DateTime.Now);
     }
 }