I am trying to create a function that provides historical volatility after receiving a symbol from Yahoo. However, when I pass the output to the volatility function, I don't like this; The Get variable is assigned a vector with quotes, for example. "SPY", but the volatility function accepts only quotation marks (SPY no "SPY"). I am trying to strip quotes with noquote () and now get the following error:
Error in log (x): non-numeric argument for math function
My code
require(quantmod)
vClose = function(X){
Get <- getSymbols(X, from="2000-01-01", src="yahoo")
Set <- noquote(Get)
volatility(Set, calc="close")
}
Any help would be great.
source
share