[R-SIG-Finance] [R-sig-finance] Garman-Klass Volatility in Rmetrics package
Ken Spriggs
ksspriggs at gmail.com
Wed Feb 13 22:25:40 CET 2008
Thanks Jeff, that works.
The Rmetrics Reference Card has the "K" in Klass capitalized. Doohhh!
Jeff Ryan wrote:
>
> Hi Ken,
>
> I *think* it is
>
> garmanklassTA
>
> no caps:
>
>> garmanklassTA
> function (open, high, low, close)
> {
> TS = is.timeSeries(open)
> if (TS) {
> x = open
> open = as.vector(open)
> high = as.vector(high)
> low = as.vector(low)
> close = as.vector(close)
> }
> prices = log(cbind(open, high, low, close))
> n = nrow(prices)
> alpha = 0.12
> f = 0.192
> u = high - open
> d = low - open
> cc = close - open
> oc = (prices[2:n, 1] - prices[1:(n - 1), 4])^2
> garmanklass = 0.511 * (u - d)^2 - 0.019 * (cc * (u + d) -
> 2 * u * d) - 0.383 * cc^2
> garmanklass = sqrt(((1 - alpha) * garmanklass[2:n])/(1 -
> f) + (alpha * oc)/f)
> garmanklass = c(NA, garmanklass)
> if (TS) {
> garmanklass = matrix(garmanklass)
> colnames(garmanklass) = "GK"
> rownames(garmanklass) = rownames(x at Data)
> x at Data = garmanklass
> }
> else {
> x = garmanklass
> }
> x
> }
>
> Jeff
>
> On Feb 13, 2008 2:51 PM, Ken Spriggs <ksspriggs at gmail.com> wrote:
>>
>> I'm looking at the Rmetrics Reference Card in the section called
>> "Additional
>> Functions" under the heading "Additional Trading Indicators" and I'm
>> wondering where the garmanKlassTA function went. When I do
>> ?garmanKlassTA
>> nothing comes up, but "garmanKlassTA" is listed in the Contents - however
>> there's no documentation that appears when you click on it.
>>
>> What has happened to the garmanKlaussTA function?
>>
>> (I also have fTrading package loaded.)
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Garman-Klass-Volatility-in-Rmetrics-package-tp15467571p15467571.html
>> Sent from the Rmetrics mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>>
>
>
>
> --
> There's a way to do it better - find it.
> Thomas A. Edison
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
>
--
View this message in context: http://www.nabble.com/Garman-Klass-Volatility-in-Rmetrics-package-tp15467571p15468350.html
Sent from the Rmetrics mailing list archive at Nabble.com.
More information about the R-SIG-Finance
mailing list