[R-SIG-Finance] I know I should be able to figure this out...

James Toll james at jtoll.com
Thu Apr 9 23:25:37 CEST 2015

> On Apr 6, 2015, at 11:59 AM, Samuel Wilson <samuelcoltwilson at gmail.com> wrote:
> I'm trying to create a script that takes a list of equity tickers (60-80
> tickers each day), and downloads their prices and puts them into
> data.frames.

I realize your question was answered, but is there a particular reason you want to make this a data.frame?  If I’m not mistaken, the performance should be better if left as xts (i.e. matrix). Might I suggest creating a list of xts?

Given your tickers:

tickers<-c("GLD","DBC", "EEM", "EFV","EFG","BND","TLT","SHY","IWF","IWD","IWC","IWO","IWN","VNQ")

Something like:


getData <- function (symbols, ...) {
  result <- mclapply(symbols, function(x) getSymbols(x, auto.assign = FALSE, ...))
  names(result) <- symbols

output <- getData(tickers)

> However, I want to build a generic engine
> using for.next loops, because the list of tickers will change each day.

Rather than for loops, write functions to do what you need, and then you can take advantage of the parallel apply functions like mclapply.

mclapply(tickers, function(x) last(output[[x]]))

Just a suggestion.


More information about the R-SIG-Finance mailing list