Quantcast
Channel: R-bloggers
Viewing all articles
Browse latest Browse all 12081

Recreating the LOB

$
0
0

(This article was first published on R and Finance, and kindly contributed to R-bloggers)

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:

library(GetHFData)

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

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

type.output <- 'raw' 

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

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)
var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' }; (function(d, t) { var s = d.createElement(t); s.type = 'text/javascript'; s.async = true; s.src = '//cdn.viglink.com/api/vglnk.js'; var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r); }(document, 'script'));

To leave a comment for the author, please follow the link and comment on their blog: R and Finance.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...


Viewing all articles
Browse latest Browse all 12081

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>