Recreating the LOB (limit order book)

Marcelo Perlin

2018-10-10

Version 1.4 of GetHFData adds functions for recreating the LOB (limit order book) from the order data. The LOB is recreated by sorting all trading orders (buy and sell) and matching them whenever there is a match of prices.

Simulating the LOB is a recursive and computer intensive problem. The current code is not optimized for speed and it may take a long time to process even a small set of financial orders.

Here’s an example of usage:

library(GetHFData)

first.time <- '10:00:00'
last.time <- '17:00:00'

first.date <- '2016-08-18' 
last.date <- '2016-08-18'

type.output <- 'raw' # aggregates data 

my.assets <- 'PETR4F' 
type.matching <- 'exact' 
type.market = 'equity-odds' 
type.data <- 'orders' # order data

df.out <- ghfd_get_HF_data(my.assets =my.assets, 
                           type.data= type.data,
                           type.matching = type.matching,
                           type.market = type.market,
                           first.date = first.date,
                           last.date = last.date,
                           first.time = first.time,
                           last.time = last.time,
                           type.output = type.output)
                           
df.lob <- ghfd_build_lob(df.out)