如何使用R从Oanda中提取数据?

时间:2015-04-22 08:42:22

标签: r quantmod

我正在使用getSymbols函数从Oanda中提取外汇日常数据:

a <- getSymbols('EUR/USD', src='oanda', from=Sys.Date()-499, 
                to=Sys.Date(), auto.assign=FALSE)

我收到以下错误消息:

Error in download.file(paste(oanda.URL, from.date, to.date, "exch=", currency.pair[1],  : 
  cannot open URL 'http://www.oanda.com/convert/fxhistory?lang=en&date1=12%2F09%2F13&date=04%2F22%2F15&date_fmt=us&exch=EUR&expr2=USD&margin_fixed=0&SUBMIT=Get+Table&format=CSV&redirected=1'
In addition: Warning message:
In download.file(paste(oanda.URL, from.date, to.date, "exch=", currency.pair[1],  :
  cannot open: HTTP status was '404 Not Found'

似乎Oanda更改了网址,我认为我不能覆盖getSymbols功能,所以在这种情况下,如何提取数据?

1 个答案:

答案 0 :(得分:1)

您可以将fImport包与代码一起使用:

oandaSeries(symbols, from = NULL, to = Sys.timeDate(),
nDaysBack = 366, ...)

详细说明可供in the package manual