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

Bar Construction

7 algorithms in Market Data Engineering · 7 with asserted arithmetic.

In this family#

  1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. 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:

ts
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.