It's generally easier to use the extractor functions Op
et al. See ?OHLC.Transformations
. Also, if you only have one symbol, you can use auto.assign=FALSE
in your call to getSymbols
to avoid the get
call all together.
s <- getSymbols("BP", auto.assign=FALSE)
If you have multiple symbols, it's easier to store them in an environment and then loop over them with eapply
:
e <- new.env()
getSymbols(stocks, env=e)
dr <- eapply(e, dailyReturn)
You can also apply TTR functions to each symbol this way.
rsi <- eapply(e, function(x) RSI(Op(x), n=14))
And you can use do.call
with cbind
to put them into a single object.
rsi_all <- do.call(cbind, rsi)