sim {bidask}R Documentation

Simulation of Open, High, Low, and Close Prices

Description

This function performs simulations consisting of n periods (e.g., days) and where each period consists of a given number of trades. For each trade, the actual price P_t is simulated as P_t = P_{t-1}e^{\sigma x}, where \sigma is the standard deviation per trade and x is a random draw from a unit normal distribution. The standard deviation per trade equals the volatility divided by the square root of the number of trades. Trades are assumed to be observed with a given probability. The bid (ask) for each trade is defined as P_t multiplied by one minus (plus) half the spread and we assume a 50% chance that a bid (ask) is observed. High and low prices equal the highest and lowest prices observed during the period. Open and Close prices equal the first and the last price observed in the period. If no trade is observed for a period, then the previous Close is used as the Open, High, Low, and Close prices for that period.

Usage

sim(
  n = 10000,
  trades = 390,
  prob = 1,
  spread = 0.01,
  volatility = 0.03,
  overnight = 0,
  drift = 0,
  units = "day",
  sign = FALSE
)

Arguments

n

the number of periods to simulate.

trades

the number of trades per period.

prob

the probability to observe a trade.

spread

the bid-ask spread.

volatility

the open-to-close volatility.

overnight

the close-to-open volatility.

drift

the expected return per period.

units

the units of the time period. One of: sec, min, hour, day, week, month, year.

sign

whether to return positive prices for buys and negative prices for sells.

Value

Simulated open, high, low, and close prices.

Note

Please cite Ardia, Guidotti, & Kroencke (2021) when using this package in publication.

References

Ardia, D., Guidotti E., & Kroencke T. A. (2021). Efficient Estimation of Bid-Ask Spreads from Open, High, Low, and Close Prices. Available at SSRN: https://www.ssrn.com/abstract=3892335


[Package bidask version 2.0.2 Index]