vwap: OHLC and VWAP

Description Usage Arguments Details Value Examples

View source: R/vwap.R

Description

Perform OHLC and VWAP on tick trades.

Usage

1
vwap(x, units, trunc_ceiling = "trunc")

Arguments

x

data.table of tick trades, columns: date, price, amount, tid, type.

units

time units period to aggregate.

trunc_ceiling

character, default trunc, also possible ceiling.

Details

Rows where amount==0 (normally should not happened) should be filtered before passing the tick data to the function.

Value

data.table aggregated to specified time units, price column is VWAP.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
suppressPackageStartupMessages(library(dwtools))

# populate tick data
suppressPackageStartupMessages(library(Rbitcoin))
tick = market.api.process("hitbtc",c("BTC","USD"),"trades")[["trades"]]
print(tick)

# ohlc + vwap
DT = vwap(tick, "30 mins")
print(DT)

# same with timing
DT = timing(vwap(tick, "30 mins"), nrow(tick))
get.timing()

# ohlc + vwap, aggregate using ceiling
DT = vwap(tick, "30 mins", "ceiling")
print(DT)

jangorecki/dwtools documentation built on May 18, 2019, 12:24 p.m.