MyNixOS website logo
Description

Efficient Estimation of Bid-Ask Spreads from Open, High, Low, and Close Prices.

Implements 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>. It also provides an implementation of the estimators described in Roll (JF, 1984) <doi:10.1111/j.1540-6261.1984.tb03897.x>, Corwin & Schultz (JF, 2012) <doi:10.1111/j.1540-6261.2012.01729.x>, and Abdi & Ranaldo (RFS, 2017) <doi:10.1093/rfs/hhx084>.

Efficient Estimation of Bid-Ask Spreads from Open, High, Low, and Close Prices

Implements the efficient estimator of bid-ask spreads from open, high, low, and close prices described in Ardia, Guidotti, & Kroencke (JFE, 2024): https://doi.org/10.1016/j.jfineco.2024.103916

Installation

install.packages("bidask")

Usage

This package implements the following functions. The function edge computes a single bid-ask spread estimate from vectors of open, high, low, and close prices. The functions edge_rolling and edge_expanding are optimized for fast calculations over rolling and expanding windows, respectively. The function spread provides additional functionalities for xts objects and implements additional estimators. The function sim simulates a time series of open, high, low, and close prices. The main functions are presented below. The full documentation is available on CRAN and a vignette is also available.

library("bidask")

Function edge

The input prices must be sorted in ascending order of the timestamp. The output value is the spread estimate. A value of 0.01 corresponds to a spread of 1%.

edge(open, high, low, close, sign=FALSE)
fielddescription
openNumeric vector of open prices.
highNumeric vector of high prices.
lowNumeric vector of low prices.
closeNumeric vector of close prices.
signWhether to return signed estimates.

Function: edge_rolling

Implements a rolling window calculation of edge. The output is a vector of rolling 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.

edge_rolling(open, high, low, close, width, sign=FALSE, na.rm=FALSE)
fielddescription
openNumeric vector of open prices.
highNumeric vector of high prices.
lowNumeric vector of low prices.
closeNumeric vector of close prices.
widthIf an integer, the width of the rolling window. If a vector with the same length of the input prices, the width of the window corresponding to each observation. Otherwise, a vector of endpoints. See examples.
signWhether to return signed estimates.
na.rmWhether to ignore missing values.

Function: edge_expanding

Implements an expanding window calculation of edge. The output is a vector of expanding 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.

edge_expanding(open, high, low, close, sign=FALSE, na.rm=TRUE)
fielddescription
openNumeric vector of open prices.
highNumeric vector of high prices.
lowNumeric vector of low prices.
closeNumeric vector of close prices.
signWhether to return signed estimates.
na.rmWhether to ignore missing values.

Examples

Load the test data.

library("bidask")
x = read.csv("https://raw.githubusercontent.com/eguidotti/bidask/main/pseudocode/ohlc.csv")

Compute the spread estimate using all the observations.

edge(x$Open, x$High, x$Low, x$Close)

Compute rolling estimates using a window of 21 observations.

edge_rolling(x$Open, x$High, x$Low, x$Close, width = 21)

Estimate the spread using custom endpoints.

edge_rolling(x$Open, x$High, x$Low, x$Close, width = c(3, 35, 100))

Estimate the spread using an expanding window

edge_expanding(x$Open, x$High, x$Low, x$Close, na.rm = FALSE)

Cite as

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

A BibTex entry for LaTeX users is:

@article{edge,
  title = {Efficient estimation of bid–ask spreads from open, high, low, and close prices},
  journal = {Journal of Financial Economics},
  volume = {161},
  pages = {103916},
  year = {2024},
  doi = {https://doi.org/10.1016/j.jfineco.2024.103916},
  author = {David Ardia and Emanuele Guidotti and Tim A. Kroencke},
}
Metadata

Version

2.1.4

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows