tseries:get.hist.quote()给出了错误的结果

时间:2012-11-23 03:46:06

标签: r time-series

根据以下代码,ROG.VX的历史引号在所选时间段内保持不变。但是,在http://finance.yahoo.com/q/hp?s=ROG.VX&a=08&b=09&c=2011&d=02&e=28&f=2012&g=d&z=66&y=132下,可以检查它们是不是(请参见屏幕截图)。怎么了?

require(tseries)
hq <- get.hist.quote(instrument="ROG.VX", start="2011-09-09", end="2012-03-28",
                     quote="Close", provider="yahoo", drop=TRUE)
plot(hq) # => constant
stopifnot(hq==138.3) # => constant 138.3

enter image description here

1 个答案:

答案 0 :(得分:1)

这是一个雅虎问题。

如果我们查看get.hist.quote()返回的信息,我们可以看到它通过http要求yahoo提供csv。我们可以轻松地将相同的URL粘贴到浏览器中以下载csv并确认这些是R正在获取的数字。并且更改日期,我们可以看到ROG.VX时间序列中的数据明显丢失,但在比较时间序列(IBM)中没有:

> rog <- get.hist.quote(instrument="ROG.VX", start="2010-06-10", end="2012-03-28",
+                      provider="yahoo", drop=TRUE)
trying URL 'http://chart.yahoo.com/table.csv?s=ROG.VX&a=5&b=10&c=2010&d=2&e=28&f=2012&g=d&q=q&y=0&z=ROG.VX&x=.csv'
Content type 'text/csv' length unknown
opened URL
downloaded 6439 bytes

> ibm <- get.hist.quote(instrument="ibm", start="2010-06-10", end="2012-03-28",
+                      provider="yahoo", drop=TRUE)
trying URL 'http://chart.yahoo.com/table.csv?s=ibm&a=5&b=10&c=2010&d=2&e=28&f=2012&g=d&q=q&y=0&z=ibm&x=.csv'
Content type 'text/csv' length unknown
opened URL
downloaded 24 Kb

> test<-merge(ibm,rog)
> plot(test)

enter image description here