I was trying to create a loop that would run through RBloomberg and download the history for a series of symbols and then chart those symbols out individually.

I came up with

start.data <- as.POSIXct("2010-08-29")
end.data <- as.POSIXct("2011-08-29")
pdf(file.path('futures.pdf'))
conn <- blpConnect()
bbrg.str <- c('es1 Index', 'ty1 comdty', 'gc1 comdty')
#fut.sym <- 'es1'
#tick.str <- bar(conn, bbrg.tick,'TRADE',start.data, end.data,"60")

for (i in 1:length(bbrg.str)){
     x <- (bbrg.str)[[i]] 
     print(x)
     y <- (x)
     y <- bdh(conn, x, c("OPEN","HIGH", "LOW","PX_LAST"), start.data, end.data)
     y <- y[2:5]
     y <- as.xts(y)
     names(y)[4] <- "Close"
     #x11()  
     chartSeries(y, name=x)
}
 which works to the extent that i get 3 windows opened and it prints all the names in the loop and the xts object is there for the last security in the list and looks fine. 

so no errors but no charts appear? I'm guessing the loop is movning too fast for the chart_Series function? but its a guess. 

on a secondary note, i would prefer to just drop them in a pdf file using ?pdf ... but i've never had any experience using that function and i seem to create file but my pdf reader errors' when i try and open it.. 'file not found'. 

any ideas appreciated. 
thx, brian

	[[alternative HTML version deleted]]

