# Orderbook Dynamics

Subscribe to measures of the orderbook state across any number of assets, on single exchanges or on a consolidated basis for a currency pair across all exchanges.

# Orderbook Imbalance

Coming Soon

This channel provides the normalized mismatch between bids and asks, by default at the top level (i.e. best bid amount minus best ask amount) but is also available at greater depths to determine the mismatch throughout the book.

$\sum_{i=1}^{n}({BidAmount_i} - {AskAmount_i})$

The orderbook levels available on which the imbalance is calculated are [1, 2, 3, ..., 25], these can be specified as part of the subscription payload.

It is also possible to get the orderbook imbalance of a Combined Orderbook on a fee-adjusted basis across all exchanges for the given currency pair.

Updates are sent on every tick where there is a change to the imbalance.

The general form of the channel is given according to the below:

{    action: 'subscribe',     channel: [exchange.instrument.imbalance.levels]}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL orderbook imbalance between the# best bid amount and the best ask amountchannel = ['deribit.BTC-PERPETUAL.imbalance.1']​# Subscribe to bitmex's XBTUSD orderbook imbalance for the top 25 levels# of the orderbookchannel = ['bitmex.XBTUSD.imbalance.25']​# Use a pattern subscription to subscribe to the top-level imbalance for all# instruments trading on bitmexchannel = ['bitmex.*.imbalance.1']​# Subscribe to the imbalance for the BTCUSD pair across all exchangeschannel = ['BTCUSD spot.imbalance.1']​

The response will be in the format:

# The orderbook imbalance on levels 1 to 5 for Gate IO's TUSD_USDT pair{   "type":"gate-io.TUSD_USDT.imbalance.1",   "exchange":"gate-io",   "symbol":"TUSD_USDT",   "value":366.01187079,   "level":1}​{   "type":"gate-io.TUSD_USDT.imbalance.2",   "exchange":"gate-io",   "symbol":"TUSD_USDT",   "value":1404.08987079,   "level":2}​{   "type":"gate-io.TUSD_USDT.imbalance.3",   "exchange":"gate-io",   "symbol":"TUSD_USDT",   "value":6554.498870789999,   "level":3}​{   "type":"gate-io.TUSD_USDT.imbalance.4",   "exchange":"gate-io",   "symbol":"TUSD_USDT",   "value":8120.59476579,   "level":4}​{   "type":"gate-io.TUSD_USDT.imbalance.5",   "exchange":"gate-io",   "symbol":"TUSD_USDT",   "value":11748.11276579,   "level":5}

# Microprice

Coming Soon

The microprice is the mid-price weighted by the bid and ask sizes in the orderbook to a given number of levels. The relation between the microprice and the mid-price is often used as an indicator of the likelihood of the price ticking in a given direction. It is most effective on exchanges where there are relatively high taker fees vs maker fees, as there is greater incentive to join the price queue at the best bid (or ask) rather than cross the spread, until the arbitrage between exchanges is sufficient to trigger a trader to cross the spread.

The formula for the Microprice is:

$S = Pa * Vb / (Va + Vb) + Pb * Va / (Va + Vb)$

Where:

$Pa = AskPrice\\Pb = Bid Price\\Va = Ask Amount\\Vb = Bid Amount$

The Microprice can be extended to include other levels, and it is possible to subscribe to levels 1 to 25 [1...25] directly.

The general form of the channel is given according to the below:

{    action: 'subscribe',     channel: [exchange.instrument.microprice.levels]}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL microprice at the first orderbook levelchannel = ['deribit.BTC-PERPETUAL.microprice.1']​# Subscribe to bitmex's XBTUSD microprice across the top 25 levels# of the orderbookchannel = ['bitmex.XBTUSD.microprice.25']​# Use a pattern subscription to subscribe to the top-level microprice for all# instruments trading on bitmexchannel = ['bitmex.*.microprice.1']​# Subscribe to the microprice for the BTCUSD pair across all exchangeschannel = ['BTCUSD spot.microprice.1']​

The response will be in the format:

# The below shows the microprice of the top 5 levels for 30th April 2021 # expiry of the BTCUSD Put option on Okex with a strike of \$48,000​{   "type":"okex-options.BTC-USD-210430-48000-P.microprice.1",   "exchange":"okex-options",   "symbol":"BTC-USD-210430-48000-P",   "value":0.03210112359550562,   "level":1}​{   "type":"okex-options.BTC-USD-210430-48000-P.microprice.2",   "exchange":"okex-options",   "symbol":"BTC-USD-210430-48000-P",   "value":0.034178807947019864,   "level":2}​{   "type":"okex-options.BTC-USD-210430-48000-P.microprice.3",   "exchange":"okex-options",   "symbol":"BTC-USD-210430-48000-P",   "value":0.034178807947019864,   "level":3}​{   "type":"okex-options.BTC-USD-210430-48000-P.microprice.4",   "exchange":"okex-options",   "symbol":"BTC-USD-210430-48000-P",   "value":0.0336,   "level":4}​{   "type":"okex-options.BTC-USD-210430-48000-P.microprice.5",   "exchange":"okex-options",   "symbol":"BTC-USD-210430-48000-P",   "value":0.0336,   "level":5}

# Orderbook Resilience

Coming Soon

Orderbook resilience is a measure of how likely the orderbook is to break in a given direction at any given time. This is a function of the number of bids and asks, recent trade arrival signs and quantities (across exchanges), short-term trends in the orderbook liquidity, longer-term time based trends - such as time of day - and price level compared to recent history.

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL Orderbook Resiliencechannel = ['deribit.BTC-PERPETUAL.resilience']​# Subscribe to bitmex's XBTUSD Orderbook Resiliencechannel = ['bitmex.XBTUSD.resilience']

# Predicted queue position

Coming Soon

Predicted queue position provides an estimate of the total quantity of bids or asks likely to be ahead of your order in the top-level price queue (i.e. best bid or best ask) if your order is submitted at that moment.

It uses the frequency of order arrivals, modeled as a Poisson process, along with known latency to the exchange and a continually updated distribution of order sizes and order prices.

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL price queue position estimatechannel = ['deribit.BTC-PERPETUAL.queue']​# Subscribe to bitmex's XBTUSD price queue position estimatechannel = ['bitmex.XBTUSD.queue']

See liquidity

See liquidity

To be updated