edge_expanding {bidask} | R Documentation |
Expanding Estimates of Bid-Ask Spreads from Open, High, Low, and Close Prices
Description
Implements an expanding window calculation of the efficient estimator of bid-ask spreads from open, high, low, and close prices described in Ardia, Guidotti, & Kroencke (JFE, 2024): doi:10.1016/j.jfineco.2024.103916.
Usage
edge_expanding(open, high, low, close, sign = FALSE, na.rm = TRUE)
Arguments
open |
numeric vector of open prices. |
high |
numeric vector of high prices. |
low |
numeric vector of low prices. |
close |
numeric vector of close prices. |
sign |
whether to return signed estimates. |
na.rm |
whether to ignore missing values. |
Details
Prices must be sorted in ascending order of the timestamp.
Value
Vector of spread estimates. A value of 0.01 corresponds to a spread of 1%. This function always returns a result of the same length as the input prices.
References
Ardia, D., Guidotti, E., Kroencke, T.A. (2024). Efficient Estimation of Bid-Ask Spreads from Open, High, Low, and Close Prices. Journal of Financial Economics, 161, 103916. doi:10.1016/j.jfineco.2024.103916
Examples
# 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)