Advances in Financial Machine Learning, Snippet 3.1, page 44. Computes the daily volatility at intraday estimation points.

daily_volatility(price, span = 50)

Arguments

price

xts object with prices or data.table object with first column is of type POSIXct

span

used to calculate alpha parameter in exponential moving average

Value

data.table with Datetime and Value columns

Examples

data("spy") daily_volatility(subset(spy, select = c("index", "close")))
#> Datetime Value #> 1: 2018-01-03 15:39:00 0.0009618423 #> 2: 2018-01-03 15:44:00 0.0010268916 #> 3: 2018-01-03 15:49:00 0.0011668355 #> 4: 2018-01-03 15:54:00 0.0012822868 #> 5: 2018-01-03 15:59:00 0.0013209074 #> --- #> 57937: 2020-12-31 21:39:00 0.0026497390 #> 57938: 2020-12-31 21:44:00 0.0026380410 #> 57939: 2020-12-31 21:49:00 0.0026500808 #> 57940: 2020-12-31 21:54:00 0.0027022664 #> 57941: 2020-12-31 21:59:00 0.0027536503