Selected volatility estimators/indicators; various authors.

volatility(OHLC, n = 10, calc = "close", N = 260, mean0 = FALSE, ...)

Object that is coercible to xts or matrix and contains Open-High-Low-Close prices (or only Close prices, if calc="close").


Number of periods for the volatility estimate.


The calculation (type) of estimator to use.


Number of periods per year.


Use a mean of 0 rather than the sample mean.

Arguments to be passed to/from other methods.


  • Close-to-Close Volatility (calc="close") $$ \sigma_{cl} = \sqrt{\frac{Z}{n-2} \sum_{i=1}^{n-1}(r_i-\bar{r})^2} $$ $$where\;\; r_i = \log \left(\frac{C_i}{C_{i-1}}\right) $$ $$and\;\; \bar{r} = \frac{r_1+r_2+\ldots +r_{n-1}}{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. $$ \sigma = \sqrt{ \frac{Z}{n} \sum \left[ \textstyle\frac{1}{2}\displaystyle \left( \log \frac{H_i}{L_i} \right)^2 - (2\log 2-1) \left( \log \frac{C_i}{O_i} \right)^2 \right] } $$

  • High-Low Volatility: Parkinson (calc="parkinson") The Parkinson formula for estimating the historical volatility of an underlying based on high and low prices. $$ \sigma = \sqrt{ \frac{Z}{4 n \times \log 2} \sum_{i=1}^{n} \left(\log \frac{H_i}{L_i}\right)^2} $$

  • 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. $$ \sigma = \sqrt{ \textstyle\frac{Z}{n} \sum \left[ \log \textstyle\frac{H_i}{C_i} \times \log \textstyle\frac{H_i}{O_i} + \log \textstyle\frac{L_i}{C_i} \times \log \textstyle\frac{L_i}{O_i} \right] } $$

  • 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. $$ \sigma = \sqrt{ \textstyle\frac{Z}{n} \sum \left[ \left( \log \textstyle\frac{O_i}{C_{i-1}} \right)^2 + \textstyle\frac{1}{2}\displaystyle \left( \log \textstyle\frac{H_i}{L_i} \right)^2 - (2 \times \log 2-1) \left( \log \textstyle\frac{C_i}{O_i} \right)^2 \right] } $$

  • 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 \(\alpha\) (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. $$ \sigma^2 = \sigma_o^2 + k\sigma_c^2 + (1-k)\sigma_{rs}^2 $$ $$ \sigma_o^2 =\textstyle \frac{Z}{n-1} \sum \left( \log \frac{O_i}{C_{i-1}}-\mu_o \right)^2 $$ $$ \mu_o=\textstyle \frac{1}{n} \sum \log \frac{O_i}{C_{i-1}} $$ $$ \sigma_c^2 =\textstyle \frac{Z}{n-1} \sum \left( \log \frac{C_i}{O_i}-\mu_c \right)^2 $$ $$ \mu_c=\textstyle \frac{1}{n} \sum \log \frac{C_i}{O_i} $$ $$ \sigma_{rs}^2 = \textstyle\frac{Z}{n} \sum \left( \log \textstyle\frac{H_i}{C_i} \times \log \textstyle\frac{H_i}{O_i} + \log \textstyle\frac{L_i}{C_i} \times \log \textstyle\frac{L_i}{O_i} \right) $$ $$ k=\frac{\alpha}{1+\frac{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.


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 original links are dead, but can be accessed via internet archives. Close-to-Close Volatility (calc="close"): https://web.archive.org/web/20100421083157/http://www.sitmo.com/eq/172 OHLC Volatility: Garman Klass (calc="garman.klass"): https://web.archive.org/web/20100326172550/http://www.sitmo.com/eq/402 High-Low Volatility: Parkinson (calc="parkinson"): https://web.archive.org/web/20100328195855/http://www.sitmo.com/eq/173 OHLC Volatility: Rogers Satchell (calc="rogers.satchell"): https://web.archive.org/web/20091002233833/http://www.sitmo.com/eq/414 OHLC Volatility: Garman Klass - Yang Zhang (calc="gk.yz"): https://web.archive.org/web/20100326215050/http://www.sitmo.com/eq/409 OHLC Volatility: Yang Zhang (calc="yang.zhang"): https://web.archive.org/web/20100326215050/http://www.sitmo.com/eq/409

See Also

See TR and chaikinVolatility for other volatility measures.

  • garman.klass
  • gk.yz
  • parkinson
  • rogers.satchell
  • volatility
  • yang.zhang
library(TTR) # NOT RUN { data(ttrc) ohlc <- ttrc[,c("Open","High","Low","Close")] vClose <- volatility(ohlc, calc="close") vClose0 <- volatility(ohlc, calc="close", mean0=TRUE) vGK <- volatility(ohlc, calc="garman") vParkinson <- volatility(ohlc, calc="parkinson") vRS <- volatility(ohlc, calc="rogers") # }
Documentation reproduced from package TTR, version 0.23-1, License: GPL-2

Community examples

Looks like there are no examples yet.