calc_var_ohlc_r: Calculate the variance of an _OHLC_ time series, using...

View source: R/HighFreq.R

calc_var_ohlc_rR Documentation

Calculate the variance of an OHLC time series, using different range estimators for variance.

Description

Calculate the variance of an OHLC time series, using different range estimators for variance.

Usage

calc_var_ohlc_r(ohlc, method = "yang_zhang", scalit = TRUE)

Arguments

ohlc

An OHLC time series of prices in xts format.

method

A character string representing the method for estimating variance. The methods include:

  • "close" close to close,

  • "garman_klass" Garman-Klass,

  • "garman_klass_yz" Garman-Klass with account for close-to-open price jumps,

  • "rogers_satchell" Rogers-Satchell,

  • "yang_zhang" Yang-Zhang,

(default is "yang_zhang")

scalit

Boolean argument: should the returns be divided by the number of seconds in each period? (default is TRUE)

Details

The function calc_var_ohlc_r() calculates the variance from all the different intra-day and day-over-day returns (defined as the differences of OHLC prices), using several different variance estimation methods.

The default method is "yang_zhang", which theoretically has the lowest standard error among unbiased estimators. The methods "close", "garman_klass_yz", and "yang_zhang" do account for close-to-open price jumps, while the methods "garman_klass" and "rogers_satchell" do not account for close-to-open price jumps.

If scalit is TRUE (the default), then the returns are divided by the differences of the time index (which scales the variance to the units of variance per second squared.) This is useful when calculating the variance from minutely bar data, because dividing returns by the number of seconds decreases the effect of overnight price jumps. If the time index is in days, then the variance is equal to the variance per day squared.

The function calc_var_ohlc_r() is implemented in R code.

Value

A single numeric value equal to the variance.

Examples

# Calculate the variance of SPY returns
HighFreq::calc_var_ohlc_r(HighFreq::SPY, method="yang_zhang")
# Calculate variance without accounting for overnight jumps
HighFreq::calc_var_ohlc_r(HighFreq::SPY, method="rogers_satchell")
# Calculate the variance without scaling the returns
HighFreq::calc_var_ohlc_r(HighFreq::SPY, scalit=FALSE)


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.