Recreating the LOB

[This article was first published on R and Finance, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Update to GetHFData (Version 1.4) –

GetHFData newest version (1.4) allows the recreation of the LOB (limit order book) based on order data. A limit order book is the standard format that trading occurs in most exchanges. Order are sent and executed whenever there is a match of order prices from sellers and buyers. Recreating the LOB is a recursive problem where all trading orders must be sorted, added and organized into a LOB object. Based on the LOB, we have information about the mid quote, best bid/ask, spread and LOB depth. These variables are usually used in studies regarding market liquidity.

I want to thank Prof. Satchit Sagade and House of Finance – Goethe Uni for inviting me as a visiting researcher in June 2017. Not only I had a wonderful time there, most of the code for the LOB reconstruction was developed during my stay.

Be aware that recreating the LOB is a computer intensive problem. The current code is not optimized for speed and may take a long time to finish, even for a few periods of trading days. Here’s an example of usage for the new code:


first.time <- '10:00:00'
last.time <- '17:00:00' <- '2015-08-18' <- '2015-08-18'

type.output <- 'raw' 

my.assets <- 'PETR4F' 
type.matching <- 'exact' = 'equity-odds' <- 'orders' 

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

To leave a comment for the author, please follow the link and comment on their blog: R and Finance. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)