Bar Construction
7 algorithms in Market Data Engineering · 7 with asserted arithmetic.
In this family#
-
Time Bars verified
Groups a trade tape into fixed-duration bars. This is the sampling scheme every chart you have seen uses, and it is a *choice*: it samples the market at a constant rate regardless of how much is happening in it.
constructBars(trades, config) -
Tick Bars verified
Closes a bar every N trades rather than every N seconds. Bars then arrive at the rate the market is transacting, so quiet periods produce fewer of them.
constructBars(trades, config) -
Volume Bars verified
Closes a bar once a target share volume has traded. Sampling by volume rather than by clock gives series with far more stable statistical properties than time bars.
constructBars(trades, config) -
Dollar Bars verified
Closes a bar once a target traded *value* is reached. Unlike volume bars this stays comparable as the price level changes — 1,000 shares of a $10 stock and of a $500 stock are not the same event.
constructBars(trades, config) -
Tick-Imbalance Bars verified
Closes a bar when signed tick flow becomes unusually one-sided relative to what recent history led you to expect. Bars are emitted on *information* rather than on elapsed time or traded quantity.
constructBars(trades, config) -
Volume-Imbalance Bars verified
The imbalance rule applied to signed *volume* rather than signed tick count, so one large order weighs more than many small ones pointing the same way.
constructBars(trades, config) -
Tick-Run Bars verified
Closes a bar when a run of same-signed trades exceeds what the recent buy probability makes plausible. Where imbalance bars react to net one-sidedness, run bars react to *persistence*.
constructBars(trades, config)
What they share#
Every topic here is a tape-aggregate, so once you have
called one the rest follow the same shape. Import paths differ only in the final segment:
import { constructBars } from "fintech-algorithms/market-data-engineering/bar-construction/time-bars";
import { constructBars } from "fintech-algorithms/market-data-engineering/bar-construction/tick-bars";Read them in the order above — the sequence is pedagogical, not alphabetical.
Where this sits#
Market Data Engineering collects 31 algorithms across 5 families. For the concept behind this family rather than the call signatures, see the concept guides.