random_taq: Calculate a random _TAQ_ time series of prices and trading...

View source: R/HighFreq.R

random_taqR Documentation

Calculate a random TAQ time series of prices and trading volumes, in xts format.

Description

Calculate a TAQ time series of random prices following geometric Brownian motion, combined with random trading volumes.

Usage

random_taq(
  volat = 6.5e-05,
  drift = 0,
  datev = seq(from = as.POSIXct(paste(Sys.Date() - 3, "09:30:00")), to =
    as.POSIXct(paste(Sys.Date() - 1, "16:00:00")), by = "1 sec"),
  bidask = 0.001,
  ...
)

Arguments

bidask

The bid-ask spread expressed as a fraction of the prices (default is 0.001=10bps).

volat

The volatility per period of the datev time index (default is 6.5e-05 per second, or about 0.01=1.0% per day).

drift

The drift per period of the datev time index (default is 0.0).

datev

The time index for the TAQ time series.

Details

The function random_taq() calculates an xts time series with four columns containing random prices following geometric Brownian motion: the bid, ask, and trade prices, combined with random trade volume data. If datev isn't supplied as an argument, then by default it's equal to the secondly index over the two previous calendar days.

Value

An xts time series, with time index equal to the input datev time index, and with four columns containing the bid, ask, and trade prices, and the trade volume.

Examples

# Create secondly TAQ time series of random prices
taq <- HighFreq::random_taq()
# Create random TAQ time series from SPY index
taq <- HighFreq::random_taq(datev=index(HighFreq::SPY["2012-02-13/2012-02-15"]))


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.