Streaming Statistics

Robust, fast statistics describing activity across all exchanges and assets to feed into stat arb strategies or inform predictions of orderbook resilience and price level changes.

Quantiles

The population quantile of the price or amount of the last 100 trades of the asset, at the given level. Currently the following levels are available [0.1, 0.25, 0.5, 0.75, 0.9, 0.99]. The general form of the channel is given according to the below:

{
    action: 'subscribe', 
    channel: [exchange.symbol.quantile.level.price/amount]
}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL trade amounts 0.99 quantile
channel = ['deribit.BTC-PERPETUAL.quantile.0.99.amount']

# Subscribe to bitmex's XBTUSD trade prices 0.50 quantile
channel = ['bitmex.XBTUSD.quantile.0.50.price']

# Use a pattern subscription to subscribe to all Bitmex instruments
# at a 0.75 quantile for both prices and amounts
channel = ['bitmex.*.quantile.0.50.*']

The response will be in the format:

# Price 0.1 Quantile
{
   "type":"delta.BTCUSDT.quantile.0.1.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100,
   "quantile":0.1
}

# Price 0.25 Quantile
{
   "type":"delta.BTCUSDT.quantile.0.25.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100,
   "quantile":0.25
}

# Price 0.50 Quantile
{
   "type":"delta.BTCUSDT.quantile.0.5.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100,
   "quantile":0.5
}

# Price 0.75 Quantile
{
   "type":"delta.BTCUSDT.quantile.0.75.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100,
   "quantile":0.75
}

# Price 0.90 Quantile
{
   "type":"delta.BTCUSDT.quantile.0.9.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100,
   "quantile":0.9
}

# Price 0.99 Quantile
{
   "type":"delta.BTCUSDT.quantile.0.99.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100,
   "quantile":0.99
}

For subscriptions to statistics for trade amounts, the response will be the same but with the type response specifying that it is a trade amount statistic, rather than a trade price statistic.

Skew

Sample skewness of the past 100 trades of a given instrument by price or amount, helpful in better understanding the distribution of trade sizes to understand the liklihood of a price level change and its direction.

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

{
    action: 'subscribe', 
    channel: [exchange.symbol.skew.price/amount]
}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL trade amounts skew
channel = ['deribit.BTC-PERPETUAL.skew.amount']

# Subscribe to bitmex's XBTUSD trade prices skew
channel = ['bitmex.XBTUSD.skew.price']

# Use a pattern subscription to subscribe to all Bitmex instruments price skew
channel = ['bitmex.*.skew.price']

The result is given by individual JSON responses:

# Price Skew
{
   "type":"delta.BTCUSDT.skew.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":0,
   "sample_size":100
}

# Amount Skew
{
   "type":"delta.BTCUSDT.skew.amount",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-0.021506618576024247,
   "sample_size":100
}

Kurtosis

Kurtosis gives the current kurtosis of the distribution implied by the past 100 trades by amount or price, for a given instrument or normalized asset across exchanges.

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

{
    action: 'subscribe', 
    channel: [exchange.symbol.kurtosis.price/amount]
}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL trade amounts kurtosis
channel = ['deribit.BTC-PERPETUAL.kurtosis.amount']

# Subscribe to bitmex's XBTUSD trade prices kurtosis
channel = ['bitmex.XBTUSD.kurtosis.price']

# Use a pattern subscription to subscribe to all Bitmex instruments price kurtosis
channel = ['bitmex.*.kurtosis.price']

The result is given by indivual JSON responses:

# Price Kurtosis
{
   "type":"delta.BTCUSDT.kurtosis.price",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.2000000000000004,
   "sample_size":100
}

# Amount Kurtosis
{
   "type":"delta.BTCUSDT.kurtosis.amount",
   "exchange":"delta",
   "symbol":"BTCUSDT",
   "value":-1.1351591435979114,
   "sample_size":100
}

Averages

You can get the mean, median, and mode properties of the past 100 trades through a simple subscription:

# Subscribe to deribit's BTC-PERPETUAL trade amount mean
channel = ['deribit.BTC-PERPETUAL.mean.amount']

# Subscribe to bitmex's XBTUSD trade prices median
channel = ['bitmex.XBTUSD.median.price']

# Use a pattern subscription to subscribe to all Bitmex instruments price kurtosis
channel = ['bitmex.*.mode.price']

k-Means Clustering

This provides the price levels of the last 100 trades, spit into 10 categories based on the k-Means approach described in:

Optimal k-means Clustering in One Dimension by Dynamic Programming Haizhou Wang and Mingzhou Song

This can be used to provide indications of likely price support levels based on recent trades, or help in identifying sources of trades based on clustering around similar prices.

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

{
    action: 'subscribe', 
    channel: [exchange.symbol.kmeans.price/amount]
}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL trade amounts k-means clustering
channel = ['deribit.BTC-PERPETUAL.kmeans.amount']

# Subscribe to bitmex's XBTUSD trade prices k-means clustering
channel = ['bitmex.XBTUSD.kmeans.price']

# Use a pattern subscription to subscribe to all Bitmex 
# instruments price k-means clustering
channel = ['bitmex.*.kmeans.price']

The result is given by individual JSON responses:

{
   "type":"gate-io-futures.BTC_USDT.kmeans.amount",
   "exchange":"gate-io-futures",
   "symbol":"BTC_USDT",
   "value":[
      [10,10,10,...,10],
      [20,20,20,...,20],
      [30,30,30,...,30,40,40,...,40],
      [50,50,50,50,60,60],
      [70,80,87],
      [100,100,...,100],
      [113,120,120],
      [150,150,160],
      [200,200,200,200],
      [442]
   ],
   "sample_size":100
}

Sample Variance

Returns the sample variance of the price or amount of the last 100 trades for a given instrument, normalized currency pair across all exchanges, or any combination of exchange and asset.

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

{
    action: 'subscribe', 
    channel: [exchange.symbol.variance.price/amount]
}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL trade amounts k-means clustering
channel = ['deribit.BTC-PERPETUAL.variance.amount']

# Subscribe to bitmex's XBTUSD trade prices k-means clustering
channel = ['bitmex.XBTUSD.variance.price']

# Use a pattern subscription to subscribe to all Bitmex instruments' price variance
channel = ['bitmex.*.variance.price']

The result is given by individual JSON responses:

# Huobi DOGEUSDT price variance
{
   "type":"huobi.DOGEUSDT.variance.price",
   "exchange":"huobi",
   "symbol":"DOGEUSDT",
   "value":3.704643049932375e-8,
   "sample_size":100
}

Note that this implementation uses Bessel's correction to give an unbiased estimator, i.e. it calculates the sample variance:

SampleVariance=Variance(n/(n1))SampleVariance = Variance * (n/(n-1))

Where n is the number of observations, i.e. 100 in all cases except for newly listed, illiquid assets that may not yet have had 100 trades in their history.

If you do not want the adjusted version, you can subscribe to the Unadjusted Standard Deviation below and simply square the result in order to get an unadjusted variance.

Sample Standard Deviation

The sample standard deviation is the short-run standard deviation of price or trade amount, or volatility when related to returns. This can be expressed as an annualized percentage or as a simple standard deviation. As above, this is adjusted for Bessel's correction in order to give the sample standard deviation, however, the unadjusted version is also available below.

The standard deviation is calculated on the last 100 trades, but is annualized based on the time between those trades - i.e for more liquid instruments the sample period is shorter, for less liquid instruments there is a longer sample period. This helps adjust for the difference in liquidity to make the measure more robust.

The annualization is based on multiplying the sample standard deviation by the square root of one year (defined as 365.25 days, given 24x7 nature of trading in underlying assets) and dividing by the sample duration:

AnnualizedStDev=SampleStDev(AnnualizationFactor/SampleDuration)AnnualizedStDev= SampleStDev*(AnnualizationFactor/SampleDuration)

The annualized version is only available for the price and returns, not for amounts, as this is not a meaningful measure.

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL price std deviation
channel = ['deribit.BTC-PERPETUAL.stdev.price']

# Subscribe to deribit's BTC-PERPETUAL volatility (%) 
channel = ['deribit.BTC-PERPETUAL.stdev.returns']

# Subscribe to bitmex's XBTUSD trade amount standard deviation
channel = ['bitmex.XBTUSD.stdev.amount']

# Use a pattern subscription to subscribe to all Bitmex instruments'
# annualized volatility
channel = ['bitmex.*.stdev.returns.annualized']

The result is given by individual JSON responses:

# Huobi DOGEUSDT linear swap Annualized Volatility
{
   "type":"huobi-dm-linear-swap.DOGE-USDT.stdev.annualized",
   "exchange":"huobi-dm-linear-swap",
   "symbol":"DOGE-USDT",
   "value":0.4784157628999617,
   "sample_size":100,
   "startTime":"2021-04-23T09:28:37.198Z",
   "endTime":"2021-04-23T09:28:37.372Z",
   "sampleDuration":174 # milliseconds
}

# Huobi DOGEUSDT linear swap sample period volatility
{
   "type":"huobi-dm-linear-swap.DOGE-USDT.stdev.price",
   "exchange":"huobi-dm-linear-swap",
   "symbol":"DOGE-USDT",
   "value":0.000035524512020846234,
   "sample_size":100
}

# Huobi DOGEUSDT linear swap sample standard deviation of trade amounts
{
   "type":"huobi-dm-linear-swap.DOGE-USDT.stdev.amount",
   "exchange":"huobi-dm-linear-swap",
   "symbol":"DOGE-USDT",
   "value":66.46695550179105,
   "sample_size":100
}

Unadjusted Standard Deviation / Volatility

This provides streaming updates to the volatility without adjusting for the sample size and is available on the same basis as the Sample Standard Deviation / Volatility:

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL price standard deviation
channel = ['deribit.BTC-PERPETUAL.rawstdev.price']

# Subscribe to deribit's BTC-PERPETUAL volatility
channel = ['deribit.BTC-PERPETUAL.rawstdev.returns']

# Subscribe to bitmex's XBTUSD trade amount standard deviation
channel = ['bitmex.XBTUSD.rawstdev.amount']

# Use a pattern subscription to subscribe to all Bitmex instruments'
# annualized volatility
channel = ['bitmex.*.rawstdev.annualized']

The result is given by individual JSON responses:

# ByBit XRPUSD Raw Annualized Volatility
{
   "type":"bybit.XRPUSD.rawstdev.annualized",
   "exchange":"bybit",
   "symbol":"XRPUSD",
   "value":1.8724994852874537,
   "sample_size":100,
   "startTime":"2021-04-23T09:47:58.749Z",
   "endTime":"2021-04-23T09:47:59.915Z",
   "sampleDuration":1166
}

# ByBit ETHUSD Raw Sample Volatility
{
   "type":"bybit.ETHUSD.rawstdev.price",
   "exchange":"bybit",
   "symbol":"ETHUSD",
   "value":0.13686723088050723,
   "sample_size":100
}

# Huobi-DM LTC-CW Raw Standard Deviation of Trade Amounts
{
   "type":"huobi-dm.LTC_CQ.rawstdev.amount",
   "exchange":"huobi-dm",
   "symbol":"LTC_CQ",
   "value":56.64714828024464,
   "sample_size":100
}

Median Absolute Deviation

The Median Absolute Deviation (MAD) is a robust measure of the variability of the trade price / amout sample. The MAD is defined as the median of the absolute deviations from the sample median.

MAD=median(XiX~){\displaystyle \operatorname {MAD} =\operatorname {median} (|X_{i}-{\tilde {X}}|)}

Where:

X~=median(X):{\displaystyle {\tilde {X}}=\operatorname {median} (X)}:

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL MAD
channel = ['deribit.BTC-PERPETUAL.mad.price']

# Subscribe to deribit's BTC-PERPETUAL volatility
channel = ['deribit.BTC-PERPETUAL.mad.returns']

# Subscribe to bitmex's XBTUSD trade amount MAD
channel = ['bitmex.XBTUSD.mad.amount']

# Use a pattern subscription to subscribe to all Bitmex instruments' price MADs
channel = ['bitmex.*.mad.price']

The result is given by individual JSON responses:

# Gate IO DOGEUSDT Sample MAD
{
   "type":"gate-io.DOGE_USDT.mad.price",
   "exchange":"gate-io",
   "symbol":"DOGE_USDT",
   "value":0.00007699999999999374,
   "sample_size":100
}

# Gate IO DOGEUSDT Annualised MAD
{
   "type":"gate-io.DOGE_USDT.mad.annualized",
   "exchange":"gate-io",
   "symbol":"DOGE_USDT",
   "value":0.34777435343726754,
   "sample_size":100,
   "startTime":"2021-04-23T10:00:57.548Z",
   "endTime":"2021-04-23T10:00:59.095Z",
   "sampleDuration":1547
}

# ByBit BTCUSD Sample Trade Amount MAD
{
   "type":"bybit.BTCUSD.mad.amount",
   "exchange":"bybit",
   "symbol":"BTCUSD",
   "value":530,
   "sample_size":100
}

Interquartile Range

The interquartile range is another measure of dispersion of the distribution of both trade prices and amounts. It is calcuated as the 3rd quartile minus the 1st quartile:

IQR=Q3Q1{\displaystyle \mathrm {IQR} =Q_{3}-Q_{1}}

Some example subscriptions are given below:

# Subscribe to deribit's BTC-PERPETUAL IQR
channel = ['deribit.BTC-PERPETUAL.iqr.price']

# Subscribe to bitmex's XBTUSD trade amount IQR
channel = ['bitmex.XBTUSD.iqr.amount']

# Use a pattern subscription to subscribe to all Bitmex instruments' price MADs
channel = ['bitmex.*.iqr.price']

The result is given by individual JSON responses:

# Trade price IQR for DOGEUSDT on Huobi
{
   "type":"huobi.DOGEUSDT.iqr.price",
   "exchange":"huobi",
   "symbol":"DOGEUSDT",
   "value":0.00002,
   "sample_size":100
}

# Trade amount IQR for DOGEUSDT on Huobi
{
   "type":"huobi.DOGEUSDT.iqr.amount",
   "exchange":"huobi",
   "symbol":"DOGEUSDT",
   "value":914.35,
   "sample_size":100
}

Correlation / Covariance

Coming Soon

Get the correlation between any two instruments on any exchange on a customizable frequency, from tick granularity through to daily correlation. You can also get the correlation of a normalized asset (the mid-price of a Combined Orderbook) with another asset, or individual instrument - for example, you could get the correlation of the BTC-PERPETUAL swap with the BTCUSD spot pair across all exchanges.

The Covariance is also available through a corresponding covariance channel.

# Subscribe to deribit's BTC-PERPETUAL correlation 
# with BTCUSD spot across all exchanges
channel = ['deribit.BTC-PERPETUAL.correlation.BTCUSD spot']

# Subscribe to bitmex's XBTUSD correlation with deribit's ETH-PERPETUAL
channel = ['bitmex.XBTUSD.correlation.deribit.ETH-PERPETUAL']

# Get the covariance for bitmex XBTUSD with deribit's BTC-PERPETUAL
channel = ['bitmex.XBTUSD.covariance.BTC-PERPETUAL']

Beta

Get the beta of any instrument to BTCUSD, see Betas for more details.

Last updated