fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Order-Flow and Impact

6 algorithms in Market Microstructure.

In this family#

  1. Order Flow Imbalance contract

    Net signed change in depth at the touch — the quantity that best explains short-horizon price moves in the microstructure literature. It counts additions and cancellations, not just trades.

    orderFlowImbalance(inputRows, resetOnSession, normalizeByDepth)
  2. Queue Imbalance contract

    The share of depth resting on the bid versus the ask. A simple, strongly predictive feature for the direction of the next price move at very short horizons.

    queueImbalance(inputRows, levels, decay)
  3. Kyle Lambda contract

    The price-impact coefficient from regressing price change on signed order flow. Lambda *is* the illiquidity parameter in Kyle's model — higher means each unit of flow moves price more.

    kyleLambda(inputRows, volumeTransform, intercept)
  4. Hasbrouck Price Impact contract

    Decomposes a trade's price effect into the permanent part — information — and the transient part that reverts. The split is what distinguishes an informed trade from a liquidity demand.

    hasbrouckPriceImpact(inputRows, horizon)
  5. PIN contract

    Probability of informed trading, estimated by maximum likelihood on daily buy and sell counts. Notoriously hard to optimise — the likelihood has flat regions and local optima, which is why the starting points are a parameter.

    pin(inputRows, starts, balancedNoise, iterations)
  6. VPIN contract

    Volume-synchronised probability of informed trading: order imbalance measured in volume buckets rather than clock time. Proposed as a flash-crash early warning, and contested — its predictive claims are actively disputed in the literature.

    vpin(inputRows, bucketVolume, windowBuckets, includePartial)

What they share#

Every topic here is a record-transform, so once you have called one the rest follow the same shape. Import paths differ only in the final segment:

ts
import { orderFlowImbalance } from "fintech-algorithms/market-microstructure/order-flow-and-impact/order-flow-imbalance";
import { queueImbalance } from "fintech-algorithms/market-microstructure/order-flow-and-impact/queue-imbalance";

Read them in the order above — the sequence is pedagogical, not alphabetical.

Where this sits#

Market Microstructure collects 29 algorithms across 5 families. For the concept behind this family rather than the call signatures, see the concept guides.