# reduce number of threads to pass CRAN checks (you can ignore this)
data.table::setDTthreads(1)
# simulate open, high, low, and close prices with spread 1%
x <- sim(n = 1000, spread = 0.01)
# estimate the spread using an expanding window
s <- edge_expanding(x$Open, x$High, x$Low, x$Close)
tail(s)
# equivalent to
s <- edge_rolling(x$Open, x$High, x$Low, x$Close, width = 1:nrow(x), na.rm = TRUE)
tail(s)
Run the code above in your browser using DataLab