Selected volatility estimators/indicators; various authors.

1 | ```
volatility(OHLC, n = 10, calc = "close", N = 260, ...)
``` |

`OHLC` |
Object that is coercible to xts or matrix and
contains Open-High-Low-Close prices (or only Close
prices, if |

`n` |
Number of periods for the volatility estimate. |

`calc` |
The calculation (type) of estimator to use. |

`N` |
Number of periods per year. |

`...` |
Arguments to be passed to/from other methods. |

Close-to-Close Volatility (

`calc="close"`

)

*sqrt(N) * runSD(ROC(Cl), n-1)*OHLC Volatility: Garman and Klass (

`calc="garman.klass"`

)

The Garman and Klass estimator for estimating historical volatility assumes Brownian motion with zero drift and no opening jumps (i.e. the opening = close of the previous period). This estimator is 7.4 times more efficient than the close-to-close estimator.

*sqrt(N/n * runSum(0.5 * log(Hi/Lo)^2 - (2*log(2)-1) * log(Cl/Op)^2, n))*High-Low Volatility: Parkinson (

`calc="parkinson"`

)

The Parkinson formula for estimating the historical volatility of an underlying based on high and low prices.

*sqrt(N/(4*n*log(2)) * runSum(log(Hi/Lo)^2, n))*OHLC Volatility: Rogers and Satchell (

`calc="rogers.satchell"`

)

The Roger and Satchell historical volatility estimator allows for non-zero drift, but assumed no opening jump.

*sqrt(N/n * runSum(log(Hi/Cl) * log(Hi/Op) + log(Lo/Cl) * log(Lo/Op), n))*OHLC Volatility: Garman and Klass - Yang and Zhang (

`calc="gk.yz"`

)

This estimator is a modified version of the Garman and Klass estimator that allows for opening gaps.

*sqrt(N/n * runSum(log(Op/lag(Cl,1))^2 + 0.5 * log(Hi/Lo)^2 - (2*log(2)-1) * log(Cl/Op)^2 , n))*OHLC Volatility: Yang and Zhang (

`calc="yang.zhang"`

)

The Yang and Zhang historical volatility estimator has minimum estimation error, and is independent of drift and opening gaps. It can be interpreted as a weighted average of the Rogers and Satchell estimator, the close-open volatility, and the open-close volatility.Users may override the default values of

*α*(1.34 by default) or*k*used in the calculation by specifying`alpha`

or`k`

in`...`

, respectively. Specifying`k`

will cause`alpha`

to be ignored, if both are provided.

*s <- sqrt(s2o + k*s2c + (1-k)*(s2rs^2))**s2o <- N * runVar(log(Op/lag(Cl,1)), n=n)**s2c <- N * runVar(log(Cl/Op), n=n)**s2rs <- volatility(OHLC, n, "rogers.satchell", N, ...)**k <- (alpha-1) / (alpha + (n+1)/(n-1))*

A object of the same class as `OHLC`

or a vector (if
`try.xts`

fails) containing the chosen volatility
estimator values.

Joshua Ulrich

The following sites were used to code/document these
indicators. All were created by Thijs van den Berg under
the GNU Free Documentation License and were retrieved on
2008-04-20. The links are currently dead, but can be
accessed via internet archives.

Close-to-Close
Volatility (`calc="close"`

):

http://www.sitmo.com/eq/172

OHLC Volatility:
Garman Klass (`calc="garman.klass"`

):

http://www.sitmo.com/eq/402

High-Low
Volatility: Parkinson (`calc="parkinson"`

):

http://www.sitmo.com/eq/173

OHLC Volatility:
Rogers Satchell (`calc="rogers.satchell"`

):

http://www.sitmo.com/eq/414

OHLC Volatility:
Garman Klass - Yang Zhang (`calc="gk.yz"`

):

http://www.sitmo.com/eq/409

OHLC Volatility:
Yang Zhang (`calc="yang.zhang"`

):

http://www.sitmo.com/eq/417

See `TR`

and `chaikinVolatility`

for other volatility measures.

1 2 3 4 5 6 | ```
data(ttrc)
ohlc <- ttrc[,c("Open","High","Low","Close")]
vClose <- volatility(ohlc, calc="close")
vGK <- volatility(ohlc, calc="garman")
vParkinson <- volatility(ohlc, calc="parkinson")
vRS <- volatility(ohlc, calc="rogers")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.