Market-Depth Analytics
8 algorithms in Market Microstructure.
In this family#
-
Cumulative Bid/Ask Depth contract
Running total of quantity available as you walk out from the touch on each side — the basis of every question about how much can be traded before price moves.
cumulativeDepth(bidsRaw, asksRaw, tickRaw) -
Top-N Depth Imbalance contract
Depth imbalance restricted to the top N levels — the same idea as queue imbalance, bounded to the part of the book that is realistically accessible.
topNDepthImbalance(bidsRaw, asksRaw, nRaw, thresholdRaw) -
Depth-at-Distance Profile contract
Depth bucketed by distance from the touch, in ticks. Shows where liquidity actually sits rather than reducing the book to a single number.
depthAtDistanceProfile(bidsRaw, asksRaw, tickRaw, maxRaw) -
Expected Market-Order Fill Price contract
Walks a market order through the book and returns the volume-weighted price it would pay. The honest answer to 'what will this cost' — and it can be a partial fill, which a naive estimate silently ignores.
expectedFillPrice(bids, asks, side, quantity, limitPrice) -
Multi-Level Sweep Cost and Slippage contract
The cost of sweeping multiple levels, measured against a chosen benchmark. Slippage is only meaningful relative to a benchmark, so which one is a parameter rather than an assumption.
sweepCostAndSlippage(bids, asks, side, quantity, benchmarkRaw, benchmarkPriceRaw, limitPrice) -
Liquidity-Wall and Concentration Detection contract
Finds levels holding disproportionate size — the 'walls' that act as short-term barriers. Worth treating with suspicion: a wall that disappears the moment price approaches it was never liquidity.
liquidityWallConcentration(levelsRaw, multipleRaw, minShareRaw, thresholdRaw) -
Depth Depletion and Replenishment contract
Tracks depth being consumed and refilled over a sequence of snapshots. The pairing matters: depletion without replenishment is a book emptying out, which is the condition preceding a dislocation.
depthDepletionReplenishment(seriesRaw) -
Market-Depth Heatmap Aggregation contract
Aggregates a sequence of book snapshots into a time-by-price grid — the data behind a depth heatmap, where persistent liquidity and fleeting quotes look completely different.
marketDepthHeatmap(snapshotsRaw, tickRaw, binRaw, maxRaw)
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:
import { cumulativeDepth } from "fintech-algorithms/market-microstructure/market-depth-analytics/cumulative-bid-ask-depth";
import { topNDepthImbalance } from "fintech-algorithms/market-microstructure/market-depth-analytics/top-n-depth-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.