如何使用Yahoo Finance YQL查询历史数据

11

我是YQL的新手。也许这很琐碎,但我还是无法完全弄清楚。例如,我知道如何使用YQL控制台从Yahoo/YQL查询当前股票数据:

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

使用查询字符串:

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

然而,如果我想要昨天或一周前的相同数据怎么办?我尝试了一些方法,比如

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

但它似乎不起作用。

欢迎提出任何建议!

3个回答

13

您使用了错误的表。

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

或者,你可以使用stockretriever.py来完成此操作。在源代码中,你可以找到一个历史数据的解决方法。


你知道在哪里可以找到ER图或可用的Yahoo.finance表格列表吗? - Diskdrive
4
据我所知,这并没有被完全屏蔽。 - weexpectedTHIS
1
它正在工作。你只需要在查询中包含store参数。将&diagnostics=true&env=store://datatables.org/alltableswithkeys附加到你的查询字符串中。 - Shahid Iqbal

9
表格是正确的。您需要在查询字符串中添加store参数。以下是示例字符串。
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

希望这能对你有所帮助。

4

yahoo.finance.historicaldata已经可用,但您必须使用startDate和endDate参数:

select * from yahoo.finance.historicaldata where symbol in ("YHOO","AAPL","GOOG","MSFT") and startDate = "2012-09-13" and endDate = "2012-09-13"

虽然表格historicaldata没有显示在控制台窗口中,但可以发现这是YQL仍然支持的一个服务。雅虎已经观察到这个特定的表格会导致服务器负载激增,并试图阻止个人使用它。 - j.raymond

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接