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:
thanks for the help. but with that code it is possible to save the current quotes in a text file(only the date-time in the first columnis not preserved). when i used read.table and tried to convert it into an xts object it shows error as it cannot take the indices as time object. same case happens if i only save the quotes in a dataframe using rbind.( i guess in the latter case that happens because the symbol ,say TCS.NS gets attached with the date). please suggest a solution to this problem. -- View this message in context: http://r.789695.n4.nabble.com/quantmod-package-tp3921071p3925863.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.