EVOLUTION-MANAGER
Edit File: volatility.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Volatility</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for volatility {TTR}"><tr><td>volatility {TTR}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Volatility</h2> <h3>Description</h3> <p>Selected volatility estimators/indicators; various authors. </p> <h3>Usage</h3> <pre> volatility(OHLC, n = 10, calc = "close", N = 260, mean0 = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>OHLC</code></td> <td> <p>Object that is coercible to xts or matrix and contains Open-High-Low-Close prices (or only Close prices, if <code>calc="close"</code>).</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>Number of periods for the volatility estimate.</p> </td></tr> <tr valign="top"><td><code>calc</code></td> <td> <p>The calculation (type) of estimator to use.</p> </td></tr> <tr valign="top"><td><code>N</code></td> <td> <p>Number of periods per year.</p> </td></tr> <tr valign="top"><td><code>mean0</code></td> <td> <p>Use a mean of 0 rather than the sample mean.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Arguments to be passed to/from other methods.</p> </td></tr> </table> <h3>Details</h3> <ul> <li><p> Close-to-Close Volatility (<code>calc="close"</code>)<br /> </p> <p style="text-align: center;"><i>sqrt(N) * runSD(ROC(Cl), n-1)</i></p> <p style="text-align: center;"><i></i></p> <p style="text-align: center;"><i></i></p> </li> <li><p> OHLC Volatility: Garman and Klass (<code>calc="garman.klass"</code>)<br /> 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.<br /> </p> <p style="text-align: center;"><i>sqrt(N/n * runSum(0.5 * log(Hi/Lo)^2 - (2*log(2)-1) * log(Cl/Op)^2, n))</i></p> </li> <li><p> High-Low Volatility: Parkinson (<code>calc="parkinson"</code>)<br /> The Parkinson formula for estimating the historical volatility of an underlying based on high and low prices.<br /> </p> <p style="text-align: center;"><i>sqrt(N/(4*n*log(2)) * runSum(log(Hi/Lo)^2, n))</i></p> </li> <li><p> OHLC Volatility: Rogers and Satchell (<code>calc="rogers.satchell"</code>)<br /> The Roger and Satchell historical volatility estimator allows for non-zero drift, but assumed no opening jump.<br /> </p> <p style="text-align: center;"><i>sqrt(N/n * runSum(log(Hi/Cl) * log(Hi/Op) + log(Lo/Cl) * log(Lo/Op), n))</i></p> </li> <li><p> OHLC Volatility: Garman and Klass - Yang and Zhang (<code>calc="gk.yz"</code>)<br /> This estimator is a modified version of the Garman and Klass estimator that allows for opening gaps.<br /> </p> <p style="text-align: center;"><i>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))</i></p> </li> <li><p> OHLC Volatility: Yang and Zhang (<code>calc="yang.zhang"</code>)<br /> 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. </p> <p>Users may override the default values of <i>α</i> (1.34 by default) or <i>k</i> used in the calculation by specifying <code>alpha</code> or <code>k</code> in <code>...</code>, respectively. Specifying <code>k</code> will cause <code>alpha</code> to be ignored, if both are provided.<br /> </p> <p style="text-align: center;"><i> s <- sqrt(s2o + k*s2c + (1-k)*(s2rs^2)) </i></p> <p style="text-align: center;"><i> s2o <- N * runVar(log(Op/lag(Cl,1)), n=n) </i></p> <p style="text-align: center;"><i></i></p> <p style="text-align: center;"><i> s2c <- N * runVar(log(Cl/Op), n=n) </i></p> <p style="text-align: center;"><i></i></p> <p style="text-align: center;"><i> s2rs <- volatility(OHLC, n, "rogers.satchell", N, ...) </i></p> <p style="text-align: center;"><i> k <- (alpha-1) / (alpha + (n+1)/(n-1)) </i></p> </li></ul> <h3>Value</h3> <p>A object of the same class as <code>OHLC</code> or a vector (if <code>try.xts</code> fails) containing the chosen volatility estimator values. </p> <h3>Author(s)</h3> <p>Joshua Ulrich </p> <h3>References</h3> <p>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.<br /> <br /> Close-to-Close Volatility (<code>calc="close"</code>):<br /> <a href="https://web.archive.org/web/20100421083157/http://www.sitmo.com/eq/172">https://web.archive.org/web/20100421083157/http://www.sitmo.com/eq/172</a><br /> <br /> OHLC Volatility: Garman Klass (<code>calc="garman.klass"</code>):<br /> <a href="https://web.archive.org/web/20100326172550/http://www.sitmo.com/eq/402">https://web.archive.org/web/20100326172550/http://www.sitmo.com/eq/402</a><br /> <br /> High-Low Volatility: Parkinson (<code>calc="parkinson"</code>):<br /> <a href="https://web.archive.org/web/20100328195855/http://www.sitmo.com/eq/173">https://web.archive.org/web/20100328195855/http://www.sitmo.com/eq/173</a><br /> <br /> OHLC Volatility: Rogers Satchell (<code>calc="rogers.satchell"</code>):<br /> <a href="https://web.archive.org/web/20091002233833/http://www.sitmo.com/eq/414">https://web.archive.org/web/20091002233833/http://www.sitmo.com/eq/414</a><br /> <br /> OHLC Volatility: Garman Klass - Yang Zhang (<code>calc="gk.yz"</code>):<br /> <a href="https://web.archive.org/web/20100326215050/http://www.sitmo.com/eq/409">https://web.archive.org/web/20100326215050/http://www.sitmo.com/eq/409</a><br /> <br /> OHLC Volatility: Yang Zhang (<code>calc="yang.zhang"</code>):<br /> <a href="https://web.archive.org/web/20100326215050/http://www.sitmo.com/eq/409">https://web.archive.org/web/20100326215050/http://www.sitmo.com/eq/409</a><br /> </p> <h3>See Also</h3> <p>See <code><a href="ATR.html">TR</a></code> and <code><a href="chaikinVolatility.html">chaikinVolatility</a></code> for other volatility measures. </p> <h3>Examples</h3> <pre> 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") </pre> <hr /><div style="text-align: center;">[Package <em>TTR</em> version 0.24.3 <a href="00Index.html">Index</a>]</div> </body></html>