我正在尝试使用quantmod::getSymbols
. 帮助文件指出,每个请求您只能下载 500 天的数据,而我从warnings()
. 尽管如此,我还是尝试创建一个循环来下载从 1997 年至今的数据。这是我的代码:
library(xts)
library(quantmod)
date_from = c("1996-01-01", "2001-01-02", "2005-01-03", "2009-01-03", "2013-01-04")
date_to = c("2001-01-01", "2005-01-02", "2009-01-03", "2013-01-03", "2016-01-04")
for (i in 1:5) {
getSymbols("EUR/AUD", src="oanda", from = dates_from[i], to = date_to[i])
forex = for (i=1) EURAUD else NULL
final_Dataset<- rbind(c(forex, EURAUD))
}
我应该实施哪些改变?
编辑 1 我让它工作了,但它写得很草率。任何提议的更改将不胜感激。
date_from = c("1996-01-01", "2001-01-02", "2005-01-03", "2009-01-03", "2013-01-04")
date_to = c("2001-01-01", "2005-01-02", "2009-01-03", "2013-01-03", "2016-01-04")
forex = vector(mode = 'list', length = 5)
for (i in 1:5) {
getSymbols("EUR/AUD", src="oanda", from = dates_from[i], to = date_to[i])
forex[[i]] = EURAUD
}
EUR_AUD = Reduce(rbind,forex)