How to Access Yahoo Finance YQL query with historical data

user780069 picture user780069 · Sep 14, 2012 · Viewed 27k times · Source

I'm new to YQL. Perhaps this is very trivial, but I couldn't quite figure this out. I know, for instance, how to query current stock data from Yahoo/YQL using the YQL console:

http://developer.yahoo.com/yql/console/

with the query string:

select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT") 

However, what if I want, say, the same data from yesterday, or a week ago? I tried things such as

select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT") and date=20120913

But it doesn't appear to work.

Any suggestion is appreciated!

Answer

Def_Os picture Def_Os · Sep 18, 2012

You're using the wrong table.

select * from yahoo.finance.historicaldata where symbol = "YHOO" and startDate = "2009-09-11" and endDate = "2010-03-10"

Alternatively, you could use stockretriever.py for this. In the source code, you can find a workaround for historical data.