[R-SIG-Finance] Slow data EOD

Ralph Vince rvince99 at gmail.com
Tue Oct 9 18:26:24 CEST 2012


I'm downloading certain equity data from yahoo on an eod basis, using
the code, below. It works wonderfully, formatting the data and dates
precisely as I am looking for EXCEPT often the data is late. Often,
the latest market day's data is not up until 10, 11 pm that night.

Is there something I am doing wrong here? Surely, yahoo must have the
data by the close. is the way I am invoking calling the file, below,
causing this? Or is there a way to obtain it from google earlier? I;d
be very grateful for any help along these lines. Ralph Vince

require(quantmod)
library(plan)
brsym <- c(
"AAPL",
"ABT",
...
"WMT",
"XOM"
);
for (i in 1:length(brsym)) {
tryCatch({
j <- paste("http://table.finance.yahoo.com/table.csv?s=",brsym[[i]],sep="");
j <- paste(j,"&g=d&ignore=.csv",sep="");
print(j);
X <- read.csv(j, header=TRUE);
# Convert the "Date" column from a factor class to a Date class
X$Date <- as.Date(X$Date)
# Sort the X object by the Date column -- order(-X$Date) will sort it
in the other direction
X <- X[order(X$Date),]
# Format the date column as you want
X$Date <- format(as.Date(X$Date),"%Y%m%d");
X <- X[,1:6]
kk <- trim.whitespace(brsym[[i]]);
k <- paste("/home/oracle/broadbaseddata/", kk, sep="");
k <- trim.whitespace(k);
k <- paste(k,".csv", sep="");
write.table(X, k, append = FALSE, quote = FALSE, sep = ",",
            eol = "\n", na = "NA", dec = ".", row.names = FALSE,
            col.names = FALSE, qmethod = c("escape", "double"));
print(k);
ko <- paste(X$Date[1], "-",X$Date[length(X$Date)]);
print(ko);
}, interrupt = function(ex) {
cat("An interrupt was detected.\n");
print(ex);
}, error = function(ex) {
cat("An error was detected.\n");
print(ex);
}, finally = {
cat("done\n");
})
}



More information about the R-SIG-Finance mailing list