11

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!

3 Answers 3

13

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.

3
  • Do you know where you can find an ER diagram or a list of yahoo.finance tables u can use?
    – Diskdrive
    Jun 19, 2013 at 10:30
  • 4
    As far as I can tell this is not blocked at all. Dec 30, 2013 at 1:07
  • 1
    It is working. You just need to include store parameter in query. append &diagnostics=true&env=store://datatables.org/alltableswithkeys with your query string. Feb 18, 2014 at 11:29
9

The table is correct. You need to append the store parameter in your query string. Here is the sample string.

http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.historicaldata where symbol = "YHOO" and startDate = "2014-02-11" and endDate = "2014-02-18"&diagnostics=true&env=store://datatables.org/alltableswithkeys

Hope it helps you.

4

yahoo.finance.historicaldata is working, but you have to use startDate and endDate:

select * from yahoo.finance.historicaldata where symbol in ("YHOO","AAPL","GOOG","MSFT") and startDate = "2012-09-13" and endDate = "2012-09-13"
1
  • Although the table historicaldata does not appear in the console window one can still find that this is a service which YQL still supports. Yahoo has observed that this particular table causes spikes in server load and has tried to discourage individuals from using it.
    – j.raymond
    Jul 8, 2013 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.