我正在使用兩個文件。第一個文件是實際的代碼和第二個文件是參考文件無法從谷歌下載R數據
##########################################
## Daily prices from Yahoo
## [email protected] - Nov. 2015
##########################################
library(quantmod)
startDate = "2014-01-01"
thePath = "D:\\daily\\data\\"
cattest <- file("D:\\daily\\error\\error.csv", open = "w")
source(paste("D:\\Reference\\","listOfInstruments.r",sep=""))
cattest <- file("D:\\daily\\error\\error.csv", open = "a")
for (ii in theInstruments)
tryCatch(
{
print(ii)
data = getSymbols(Symbols = ii,
src = "google",
from = startDate,
auto.assign = TRUE,verbose = TRUE)
colnames(data) = c("Date","Open","High","Low","Close","Volume")
write.zoo(data,paste(thePath,ii,".csv",sep=""),sep=",",row.names=FALSE)
}
,error=function(e){cat(ii, "\n", file=cattest)})
close(cattest)
我試圖下載使用下面的代碼來自谷歌的數據,但它不下載任何東西什麼我做錯了這裏
Reference file
##########################################
## List of securities (Yahoo tickers)
## [email protected] - Nov. 2015
##########################################
theInstruments = c("^GSPC",
"SPY",
"QQQ",
"DDM",
"EFA",
"EEM",
"EWJ")
錯誤似乎是
done.
Warning messages:
1: In fname %in% c("break", "next") :
closing unused connection 3 (D:\daily\error\error.csv)
2: In download.file(paste(google.URL, "q=", Symbols.name, "&startdate=", :
cannot open URL 'http://finance.google.com/finance/historical?q=^GSPC&startdate=Jan+01,+2014&enddate=Jun+16,+2017&output=csv': HTTP status was '404 Not Found'
你得到什麼樣的錯誤/消息的? – AK88
@ AK88更新問題 – NewtoPython