IteraLabs / atelier

A Computational Framework/Engine for Market Microstructure High Frequency Modeling, Synthetic Simulation and Historical Market Reconstruction/Replay
https://www.iteralabs.ai
3 stars 2 forks source link

Create Orderbook Metrics #11

Closed IFFranciscoME closed 2 months ago

IFFranciscoME commented 2 months ago

Context

For almost any operational objective, having the functionality to calculate a value, transformation or metric from an Orderbook is a basic one.

Problem

There is no functionality related to produce metrics and calculations applied to an Orderbook dataType. Not even the most basic metrics like mid_price, vwap, etc.

now, there is a way of categorizing orderbook metrics, those who are static in time (requiring only 1 orderbook instance), and those who are dynamic in time (requiring > 1 orderbook instances).

For this ticket, only static-in-time metrics are defined. The other dynamic-in-time ones can refer to this ticket as context.

Solution

Create a module that contains the calculations definitions to calculate metrics based on Orderbook data.

Success Criteria

metrics as a module has functionality related to the calculation of metrics for any single or progression of Orderbook data, in particular, using a selected fraction of the Orderbook data, which consists in the selection of $D$ number of levels (symmetrically). The necessary metrics are:

Spread

$$ spread{t} = P{t}^{b, 0} - P_{t}^{a, 0} $$

Midprice

$$ midprice{t} = \frac{P{t}^{b, 0} + P_{t}^{a, 0}}{2} $$

Volume-Weighted Average Price (VWAP)

$$ VWAP{t} ^{D} = \sum {i=0} ^{n=D} \frac{ P{t}^{b, i} * V{t}^{b, i} + P{t}^{a, i}*V{t}^{a, i} } { V{t}^{b, i} + V{t}^{a, i}} $$

Volume Imbalance

$$ \rho{t} ^ {D} = \sum{i=0} ^{n=D} \frac{V{t}^{b, i} - V{t}^{a, i} }{ V{t}^{b, i} + V{t}^{a, i} } $$