Skip to content
Prev 275127 / 398506 Next

quantmod package

You have to convert the long numbers to time objects; they are kept as
POSIXct values so just apply as.POSIXct() to them. However, you may
just want to store the time data as a string containing the same info:
try this,

library(quantmod)

tck = "YHOO"
filename = paste(tck, ".txt", sep="")

while(TRUE){
    temp <- getQuote(tck)
    temp <- paste(temp[[1]], temp[[2]], "\n", sep = ",")
    cat(file = filename, temp, append = TRUE)
    Sys.sleep(1/10)
}

P = read.table(filename, stringsAsFactors = FALSE, sep=",")
P = xts(P[,2], as.POSIXct(P[,1])); names(P) <- tck

Michael
On Fri, Oct 21, 2011 at 11:30 AM, ATANU <ata.sonu at gmail.com> wrote: