obAnalytics-package: obAnalytics.
Description
Limit order book analytics.
Main functionality
- Limit order book event processing.
- Visualise order book state and market impacts.
- Order book reconstruction and analysis.
Data processing
The main focus of this package is reconstruction of a limit order book.
The processData
function will perform data processing based on
a supplied CSV file, the schema of which is defined in the
processData
function documentation. Example preprocessed limit
order data are also provided (see lob.data
) which has been
derived from the example raw data provided the inst/extdata directory. The data processing consists of a number of stages:
- Cleaning of duplicate and erroneous data.
- Identification of sequential event relationships.
- Inference of trade events via order-matching.
- Inference of order types (limit vs market).
- Construction of volume by price level series.
- Construction of order book summary statistics.
Limit order events are related to one another by volume deltas (the
change in volume for a limit order). To simulate a matching-engine, and thus
determine directional trade data, volume deltas from both sides of the limit
order book are ordered by time, yielding a sequence alignment problem, to
which the the
Needleman-Wunsch
algorithm has been applied.Visualisation
The package provides a number of functions for the visualisation of limit
order events and order book liquidity. The visualisations all make use of
the ggplot2 plotting system:
The plotPriceLevels
visualisation is designed to show the
ebb and flow of limit order volume at all price levels including the
interplay between the bid/ask spread. It is possible to identify interesting
market participant behaviour and to visualise market shocks and resilience
with this function. The plotEventMap
function is useful for studying systematic
market participant behaviour. Interesting sequential patterns can be observed
in this visualisation as algorithms react to various market events by
repositioning orders. The plotVolumeMap
function shows a visualisation of cancelled
volume through time. It is possible to identify and filter out individual
trading algorithms from this graph. The plotVolumePercentiles
visualisation is inspired by the size
map chart included in many articles from
Nanex research and is intended to
show available market liquidity. In all visualisations it is possible to filter the data by time, price and
volume.Analysis
In addition to the generated lob.data
which are intended to be
used as a basis for further research, the package currently provides a
limited set of trade and order book analysis functions:
Additional functionality will be added to the package in the future.