calc_hurst_ohlc: Calculate the Hurst exponent from the volatility ratio of...

View source: R/RcppExports.R

calc_hurst_ohlcR Documentation

Calculate the Hurst exponent from the volatility ratio of aggregated OHLC prices.

Description

Calculate the Hurst exponent from the volatility ratio of aggregated OHLC prices.

Usage

calc_hurst_ohlc(
  ohlc,
  step,
  method = "yang_zhang",
  closel = 0L,
  scale = TRUE,
  index = 0L
)

Arguments

ohlc

A time series or a matrix of OHLC prices.

step

The number of time periods in each interval between neighboring end points.

method

A character string representing the price range estimator for calculating the variance. The estimators include:

  • "close" close-to-close estimator,

  • "rogers_satchell" Rogers-Satchell estimator,

  • "garman_klass" Garman-Klass estimator,

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

  • "yang_zhang" Yang-Zhang estimator,

(The default is the method = "yang_zhang".)

closel

A vector with the lagged close prices of the OHLC time series. This is an optional argument. (The default is closel = 0).

scale

Boolean argument: Should the returns be divided by the time index, the number of seconds in each period? (The default is scale = TRUE).

index

A vector with the time index of the time series. This is an optional argument (the default is index = 0).

Details

The function calc_hurst_ohlc() calculates the Hurst exponent from the ratios of the variances of aggregated OHLC prices.

The aggregated volatility \sigma_t increases with the length of the aggregation interval \Delta t. The aggregated volatility increases as the length of the aggregation interval \Delta t raised to the power of the Hurst exponent H:

\sigma_t = \sigma {\Delta t}^H

Where \sigma is the daily return volatility.

The Hurst exponent H is equal to the logarithm of the ratio of the volatilities divided by the logarithm of the time interval \Delta t:

H = \frac{\log{\sigma_t} - \log{\sigma}}{\log{\Delta t}}

The function calc_hurst_ohlc() calls the function calc_var_ohlc_ag() to calculate the aggregated variance \sigma^2_t.

Value

The Hurst exponent calculated from the volatility ratio of aggregated OHLC prices.

Examples

## Not run: 
# Calculate the log ohlc prices
ohlc <- log(rutils::etfenv$VTI)
# Calculate the Hurst exponent from 21 day aggregations
calc_hurst_ohlc(ohlc, step=21)

## End(Not run)


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