orderBook: Instantaneous limit order book reconstruction.

Description Usage Arguments Details Value Author(s) Examples

View source: R/order-book-reconstruction.R

Description

Given a set of events, reconstructs a limit order book for a specific point in time.

Usage

1
2
orderBook(events, tp = as.POSIXlt(Sys.time(), tz = "UTC"),
  max.levels = NULL, bps.range = 0, min.bid = 0, max.ask = Inf)

Arguments

events

Limit order events data.frame.

tp

Time point to re-construct order book at.

max.levels

Max number of price levels to return.

bps.range

Max depth to return +- BPS from best bid/ask.

min.bid

Min bid to return.

max.ask

Max ask to return.

Details

An order book consists of 2 sides: bids and asks, an example of which is shown below:

id price volume liquidity bps
65613703 236.58 910229141 6341547077 2.11
65613655 236.56 1320000000 5431317936 1.26
65613700 236.55 1320000000 4111317936 0.84
65613698 236.54 1600000000 2791317936 0.42
65613712 236.53 1191317936 1191317936 0.00
- - - - -
65613225 236.36 16154172 16154172 0.00
65613681 236.31 200000000 216154172 2.11
65613220 236.30 100000000 316154172 2.53
65612978 236.28 100000000 416154172 3.38
65612388 236.17 100000000 516154172 8.03

Value

Limit Order Book structure. A list containing 3 fields:

timestamp

Timestamp the order book was reconstructed for.

asks

A data.frame containing the Ask side of the order book.

bids

A data.frame containing the Bid side of the order book.

The bids and asks data consists of the following:

id

Limit order Id.

timestamp

Last modification time to limit order.

exchange.timestamp

Time at which order was placed in order book.

price

Limit order price.

volume

Limit orer volume.

liquidity

Cumulative sum of volume from best bid/ask up until price.

bps

Distance (in BPS) of order from best bid/ask.

Both the bids and asks data are ordered by descending price.

Author(s)

phil

Examples

1
2
tp <- as.POSIXct("2015-05-01 04:25:15.342", tz="UTC")
orderBook(lob.data$events, max.levels=5)

obAnalytics documentation built on May 1, 2019, 7:04 p.m.