2
votes

I'd like to get past values of stocks using the Yahoo finance API.
I found this article: http://www.codeproject.com/Articles/37550/Stock-quote-and-chart-from-Yahoo-in-C
but I can only get the stock's latest value.
Does anybody know if it is even possible to get a stock's value by date using this API (or any other)?

2

2 Answers

2
votes

You can use the YQL Api for Yahoo Finance, see here.

The url to query is the following:
"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22"+symbol+"%22%20and%20startDate%20%3D%20%22"+ startDate +"%22%20and%20endDate%20%3D%20%22"+ endDate +"%22"+ dataFormat

where:
- symbol is the list of tickers, for example 'AAPL', 'MSFT', 'YHOO'
- startDate is the first day of quotations
- endDate is the final day of quotations
- dataFormat is the following string:

&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

The result is a XML file you can fetch to retrieve historical values.
I advise you to use the YQL console a lot in the beginning to create the exact request you want.