Learn R Programming

obAnalytics (version 0.1.1)

orderBook: Instantaneous limit order book reconstruction.

Description

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

Usage

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.

Value

Limit Order Book structure. A list containing 3 fields:
The bids and asks data consists of the following:
Both the bids and asks data are ordered by descending price.

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 id price volume liquidity bps

Examples

Run this code

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

Run the code above in your browser using DataLab