scrub_agg: Scrub a single day of _TAQ_ data, aggregate it, and convert...

View source: R/HighFreq.R

scrub_aggR Documentation

Scrub a single day of TAQ data, aggregate it, and convert to OHLC format.

Description

Scrub a single day of TAQ data, aggregate it, and convert to OHLC format.

Usage

scrub_agg(
  taq,
  look_back = 51,
  vol_mult = 2,
  period = "minutes",
  tzone = "America/New_York"
)

Arguments

period

The aggregation period.

Details

The function scrub_agg() performs:

  • index timezone conversion,

  • data subset to trading hours,

  • removal of duplicate time stamps,

  • scrubbing of quotes with suspect bid-ask spreads,

  • scrubbing of quotes with suspect price jumps,

  • cbinding of mid prices with volume data,

  • aggregation to OHLC using function to.period() from package xts,

Valid 'period' character strings include: "minutes", "3 min", "5 min", "10 min", "15 min", "30 min", and "hours". The time index of the output time series is rounded up to the next integer multiple of 'period'.

Value

A OHLC time series in xts format.

Examples

# Create random TAQ prices
taq <- HighFreq::random_taq()
# Aggregate to ten minutes OHLC data
ohlc <- HighFreq::scrub_agg(taq, period="10 min")
chart_Series(ohlc, name="random prices")
# scrub and aggregate a single day of SPY TAQ data to OHLC
ohlc <- HighFreq::scrub_agg(taq=HighFreq::SPY_TAQ)
chart_Series(ohlc, name=symbol)


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