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

Continuous Matching

4 algorithms in Matching Engines and Venue Logic.

In this family#

  1. Price-Time Priority contract

    Matches an incoming order against resting orders by best price, then earliest arrival. The default rule on most equity venues, and the one that makes queue position valuable. Prices and quantities are integer **atoms** — the venue's minimum increment — not floating-point currency. Matching arithmetic that rounds is matching arithmetic that disagrees with the exchange.

    priceTimePriority(incomingRaw, restingRaw)
  2. Pro-Rata Matching contract

    Allocates a fill across all resting orders at a price in proportion to size, ignoring arrival time. Common in some futures markets, and it removes the incentive to queue that price-time creates — participants instead inflate size.

    proRataMatching(incomingRaw, priceRaw, lotRaw, restingRaw)
  3. Size-Time Priority contract

    Orders by size first and arrival second — rewarding large resting orders. Used where a venue wants to attract size rather than speed.

    sizeTimePriority(incomingRaw, priceRaw, lotRaw, restingRaw)
  4. Hybrid Pro-Rata/Time Matching contract

    Splits an incoming order between a time-priority portion and a pro-rata portion — the compromise most futures venues actually run, because pure pro-rata invites size inflation and pure price-time invites a latency race.

    calculate(topicId, inputs)

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 { priceTimePriority } from "fintech-algorithms/matching-engines-and-venue-logic/continuous-matching/price-time-priority";
import { proRataMatching } from "fintech-algorithms/matching-engines-and-venue-logic/continuous-matching/pro-rata-matching";

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

Where this sits#

Matching Engines and Venue Logic collects 21 algorithms across 4 families. For the concept behind this family rather than the call signatures, see the concept guides.