fintech-algorithms

Roll Spread Estimator

Install and import

bash
npm install fintech-algorithms
ts
import { rollSpread } from "fintech-algorithms/market-microstructure/liquidity-and-spreads/roll-spread-estimator";

Signature

rollSpread(prices)

Infers the effective spread from the negative serial covariance of price changes alone — no quote data required. When the covariance comes out positive the model is contradicted, and reporting zero rather than an imaginary number is the honest handling.

Parameters

NameTypeNotes
pricesnumber[]Trade price series, chronological.

Returns

{ spread, covariance, valid, … }

The implied spread with the covariance behind it and a validity flag for the positive-covariance case.

Errors

  • When fewer than three prices are supplied — throws

Complexity: time O(n), space O(1).

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

prices
[100, 100.05, 100.01, 100.06, 100.02, 100.07]

Call

rollSpread(prices)

Returns

object with 11 fields: model, observation_count, change_count, covariance_pair_count, lag1_price_change_covariance, covariance_tolerance, mean_price, spread_estimate, …

{
  "model": "roll-spread",
  "observation_count": 6,
  "change_count": 5,
  "covariance_pair_count": 4,
  "lag1_price_change_covariance": -0.0026999999999997785,
  "covariance_tolerance": 1e-15,
  "mean_price": 100.03500000000001,
  "spread_estimate": 0.10392304845412838,
  "spread_estimate_relative": 0.0010388668811328872,
  "spread_estimate_bps": 10.388668811328872,
  "state": "estimated"
}

Other exports

This module also exports quotedSpread, effectiveSpread, realizedSpread, amihudIlliquidity, corwinSchultzSpread, calculate. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams

Roll Spread Estimator — calculation map
Roll Spread Estimator — decision boundary
Roll Spread Estimator — failure boundary
Roll Spread Estimator — scenario matrix
Roll Spread Estimator — system map

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References

  • Roll (1984), A Simple Implicit Measure of the Effective Bid-Ask Spread — The Journal of Finance
  • NYSE Daily TAQ product description — New York Stock Exchange