get.hist.quote() 是否仍然使用 source=yahoo Finance 返回数据? [英] Is get.hist.quote() still returning data with source=yahoo finance?

查看:92
本文介绍了get.hist.quote() 是否仍然使用 source=yahoo Finance 返回数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

纽约.正如主题行中的问题所暗示的那样,我在尝试使用 tseries 包函数 get.hist.quote() 时遇到错误.任何人都可以解释我错误地调用它,或者改变了它的签名/功能?

HNY. As the question in the subject line implies, I'm getting errors trying to use the tseries package function get.hist.quote(). Can anyone shed light on my calling it incorrectly, or in a change of its signature/functionality?

我从昨天开始工作时就注意到了这些错误.今天在我的家用机器上,同样的问题.符号、开始/结束日期和粒度(日与月)的各种组合的结果相同.

I noticed these errors starting at my work yesterday. Today on my home machine, same issue. Same results for various combinations of symbol, start/end dates, and granularity (day vs month).

这是一个例子:

> spy = get.hist.quote(instrument= 'SPY', 
                       start = "2000-01-01", 
                       end = "2013-10-31",
                       quote="AdjClose", 
                       provider = "yahoo", 
                       origin="1970-01-01", 
                       compression = "m",
                       retclass="zoo")

trying URL 'http://chart.yahoo.com/table.csv?s=SPY&a=0&b=01&c=2000&d=9&e=31&f=2013&g=m&q=q&y=0&z=SPY&x=.csv'
download error, retrying ...
trying URL 'http://chart.yahoo.com/table.csv?s=SPY&a=0&b=01&c=2000&d=9&e=31&f=2013&g=m&q=q&y=0&z=SPY&x=.csv'
download error, retrying ...
trying URL 'http://chart.yahoo.com/table.csv?s=SPY&a=0&b=01&c=2000&d=9&e=31&f=2013&g=m&q=q&y=0&z=SPY&x=.csv'
download error, retrying ...
trying URL 'http://chart.yahoo.com/table.csv?s=SPY&a=0&b=01&c=2000&d=9&e=31&f=2013&g=m&q=q&y=0&z=SPY&x=.csv'
download error, retrying ...
trying URL 'http://chart.yahoo.com/table.csv?s=SPY&a=0&b=01&c=2000&d=9&e=31&f=2013&g=m&q=q&y=0&z=SPY&x=.csv'
Error in get.hist.quote(instrument = "SPY", start = "2000-01-01", end = "2013-10-31",  : 
  cannot open URL 'http://chart.yahoo.com/table.csv?s=SPY&a=0&b=01&c=2000&d=9&e=31&f=2013&g=m&q=q&y=0&z=SPY&x=.csv'
In addition: Warning messages:
1: In download.file(url, destfile, method = method, quiet = quiet) :
  InternetOpenUrl failed: 'A connection with the server could not be established'
2: In download.file(url, destfile, method = method, quiet = quiet) :
  InternetOpenUrl failed: 'A connection with the server could not be established'
3: In download.file(url, destfile, method = method, quiet = quiet) :
  InternetOpenUrl failed: 'A connection with the server could not be established'
4: In download.file(url, destfile, method = method, quiet = quiet) :
  InternetOpenUrl failed: 'A connection with the server could not be established'
5: In download.file(url, destfile, method = method, quiet = quiet) :
  InternetOpenUrl failed: 'A connection with the server could not be established'

推荐答案

将其源代码复制到本地函数并将基本 URL 更改为 http://ichart.finance.yahoo.com:

Copy its source code into a local function and change the base URL to http://ichart.finance.yahoo.com:

R> myghq <- tseries::get.hist.quote
R> fix(myghq)                      # doing the local edit on the fly
Waiting for Emacs...
R>

我现在有一个带有更正 URL 的函数,可以从中查询.

I now have a function with a corrected URL from which to query.

这里有一个请求 SPY 的例子:

So here is an example requesting SPY:

R> spy <- myghq("SPY")
trying URL 'http://ichart.finance.yahoo.com/table.csv \   # manual break
?s=SPY&a=0&b=02&c=1991&d=11&e=31&f=2013&g=d&q=q&y=0&z=SPY&x=.csv'
Content type 'text/csv' length unknown
opened URL
.......... .......... .......... .......... ..........
.......... .......... .......... .......... ..........
.......... .......... .......... .......... ..........
.......... .......... .......... .......... ..........
.......... .......... .......... .......... ..........
.......... .......... .
downloaded 271 Kb

time series starts 1993-01-29
R> 

这篇关于get.hist.quote() 是否仍然使用 source=yahoo Finance 返回数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆