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

Samuel Wilson samuelcoltwilson at gmail.com
Mon Apr 6 18:59:28 CEST 2015

As an experienced R Programmer, I should be able to figure this out, but
I'm stuck.  I'm sure the answer is obvious, but for some reason I just
can't get my brain to wrap around the answer.

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 usually use the getSymbols command, but here is the issue.
The I somehow need to be able to put the output of getSymbols to generic
variables.  For example, "stock[1]", "stock[2]", etc.  This way I can use a
generic loop to transform the data and output it to the next step.

When I traditionally use the getSymbols command, the return is the equity
ticker with the OLHC prices.  However, I want to build a generic engine
using for.next loops, because the list of tickers will change each day.

Is the issue I can't use getSymbols?  or is the issue that somehow I need
to use the upfront ticker list as a variable list and make it work, but
there is a class of variable I don't understand.  Because if I use a
variable call generically list[1], it does not return the stock prices.

tickers<-c("GLD","DBC", "EEM", "EFV",
getSymbols(tickers, from="2013-01-01")

For example, if I just do a tickers[1] in the console, I get "GLD" not the
OLHC prices for GLD.  How do I get tickers[1] as a variable I can use to
pull the prices out of?  Because tickers[1] will change everyday (this is
just a made up example).

As I said, I'm sure some is going to look at this and say, Really?  but for
some reason I just can't get my brain wrapped around it.


	[[alternative HTML version deleted]]

More information about the R-SIG-Finance mailing list