I'm trying to collect mutual fund performance data via open and close prices from quantmod. I have scraped a list of 5000 some funds and am trying to loop through and get one open and close price for each fund. I'm having difficulty calling the xts object yielded by getSymbols()
as it is called invisibly into the environment. Since the object is stored as its ticker name, I tried calling it by its ticker name.
Code so far:
## loop thru list and use quantmod to calculate performance from 1/2/14 to 12/31/14
for(i in 1:4881){
ticker <- tickernames[i]
getSymbols(ticker)
Open <- ticker["2014-01-02",1]
Close <- ticker["2014-12-31",4]
performance2014[i] = (Open - Close)/Open
}
Is there a way I can call the object using ls()
?