Sta*_*Csh 3 r quantmod yahoo-finance
HNY.正如主题中的问题所暗示的那样,我在尝试使用tseries包函数时遇到错误get.hist.quote().任何人都可以解释我的错误调用,或更改其签名/功能?
我昨天在工作中注意到这些错误.今天在我的家用机器上,同样的问题.符号,开始/结束日期和粒度(日与月)的各种组合的结果相同.
这是一个例子:
> 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'
Run Code Online (Sandbox Code Playgroud)
将其源代码复制到本地函数并将基本URL更改为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>
Run Code Online (Sandbox Code Playgroud)
我现在有一个带有更正URL的函数,可以从中查询.
所以这是一个请求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>
Run Code Online (Sandbox Code Playgroud)