# simulate open, high, low, and close prices with spread 1%
x <- sim(spread = 0.01)
# estimate the spread
spread(x)
# by default this is equivalent to
edge(x$Open, x$High, x$Low, x$Close)
# estimate the spread using a rolling window of 21 periods
spread(x, width = 21)
# estimate the spread for each month
ep <- xts::endpoints(x, on = "months")
spread(x, width = ep)
# use multiple estimators
spread(x, method = c("EDGE", "AR", "CS", "ROLL", "OHLC", "OHL.CHL"))
Run the code above in your browser using DataLab