consolidate_prices: Consolidate prices at a specified resolution

Description Usage Arguments Value Examples

View source: R/process.R

Description

Consolidate prices at a specified resolution

Usage

1
2
consolidate_prices(date, time, price, size, date_format = "%Y-%m-%d",
  time_format = "%H:%M:%OS", on = "seconds", k = 1)

Arguments

date

transaction date strings

time

transaction time strings

price

a tranaction prices

size

a transaction sizes

date_format

the format for the sys_date column (default is "%Y-%m-%d").

time_format

the format for the sys_time column (default is "%H:%M:%S.%f").

on

the resolution to consolidate trades. The default is "seconds" and any resolution supported by the xts::endpoints function is valid.

k

along every k-th elements. For example if "seconds" is specified as the "on" parameter and k=2 then prices are consolidated for every 2 seconds.

Value

an xts object with (vwapped) price, max price, min price, and volume.

Examples

1
2
3
4
5
6
7
8
9
# Consolidate TAQ trades...
data(aapl_taq)
ctp = consolidate_prices(aapl_taq$sys_date, aapl_taq$sys_time,
 aapl_taq$td_price, aapl_taq$td_size, date_format="%Y%m%d",
 time_format="%H:%M:%S")
# or FIX trades...
data(aapl_fix)
cfp = consolidate_prices(aapl_fix$sys_date, aapl_fix$sys_time,
 aapl_fix$td_price, aapl_fix$td_size)

hafen/nxcore documentation built on May 17, 2019, 2:03 p.m.