Open Source MIT License • Python & TypeScript

Open-Source Microstructure Tooling

We maintain orderflow-metrics — a dependency-free library of the market-microstructure metrics institutional desks take for granted, implemented cleanly, tested, and free to read. It ships in both Python (on PyPI) and TypeScript, with the same API surface.

PyPI version Python versions GitHub stars License MIT Zero dependencies

What's inside

The library covers the core building blocks of order-flow and execution analysis — the same primitives behind our market microstructure analytics and quantitative research.

Family What it computes
Order Flow ImbalanceLevel-1 OFI (Cont–Kukanov–Stoikov), per-step and cumulative
ImbalanceTop-of-book depth imbalance and trade imbalance
VPINFlow toxicity via volume bucketing and bulk-volume classification
Information-driven barsTick, volume, and dollar bars
Execution / TCAEffective & realized spread, price impact, Kyle's lambda, Roll's estimator
Fair valueMid, imbalance-weighted micro-price, relative spread (bps)
Trade-sign classificationTick rule and Lee-Ready
Liquidity & volatilityAmihud illiquidity, realized & annualized volatility
Market efficiencyAutocorrelation and the Lo-MacKinlay variance ratio
Order bookReconstruction from incremental updates; depth and imbalance
Market-order simulationSweep the book for VWAP fill, slippage, and unfilled size
Execution schedulingTWAP and percentage-of-volume slicers

Install & use

Python — published on PyPI:

pip install orderflow-metrics
from orderflow_metrics import ofi, dollar_bars, vpin

bars = dollar_bars(trades, 250_000)      # sample by activity, not the clock
signal = ofi(quotes)                      # net top-of-book pressure
toxicity = vpin(bucket_by_volume(trades, 1_000))

TypeScript — dependency-free, runs on Node 22+ with no build step. Read the code or vendor the src/ directory directly from GitHub:

import { ofi, dollarBars, vpin } from "orderflow-metrics";

Why we open-source it

Good microstructure primitives shouldn't be a black box. Publishing them cleanly — dependency-free, tested, and documented — is how we think trading technology should be built: legible, verifiable, and reusable. The library is also the sampling and signal layer that our infrastructure and research build on. It is educational and technical material only — not investment advice.

Explore the code, install the package, or open an issue:

💻 GitHub 🐍 PyPI 📚 Research