Exemplo n.º 1
0
        private void InitializePrices()
        {
            string csvData;

            if (Stocks == null)
            {
                throw new Exception("Failed to retrieve symbols.");
            }

            string url = Definitions.YahooFinanceUrl;

            foreach (var stock in Stocks)
            {
                url += stock.Symbol + "+";
            }

            url = url.TrimEnd('+') + "&f=";

            url = string.Format("{0}{1}{2}{3}{4}", url, PriceInfoKeys.Bid, PriceInfoKeys.Ask, PriceInfoKeys.Open, PriceInfoKeys.PreviousClose);

            using (WebClient web = new WebClient())
            {
                csvData = web.DownloadString(url);
            }

            Prices = YahooFinance.ParsePrice(csvData, Stocks);
        }