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

Order Controls

6 algorithms in Matching Engines and Venue Logic.

In this family#

  1. Tick-Size Validation contract

    Rejects a price that is not a whole multiple of the instrument's tick. 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. Validating in floating point is how sub-tick prices reach a book that cannot represent them.

    tickSizeValidation(price_atoms, tick_size_atoms, price_scale, effective_policy_id)
  2. Price-Band Validation contract

    Checks a limit price against the venue's dynamic price band. Bands move with the reference price, so a valid order becomes invalid moments later — which is why the band's as-of time is part of the check.

    priceBandValidation(side, limit_price_atoms, lower_band_atoms, upper_band_atoms, band_as_of_ns, inclusive)
  3. Self-Trade Prevention contract

    Stops a participant trading with itself — required by most venues, and the *mode* determines who loses their order. Cancel-newest, cancel-oldest and cancel-both give materially different outcomes for queue position.

    selfTradePrevention(incoming_order, resting_orders, mode)
  4. Cancel-on-Disconnect contract

    Decides which orders to pull when a session drops. Not every disconnect should cancel — a deliberate logout and a network failure are different events, and cancelling a hedge because of a brief blip is its own risk.

    cancelOnDisconnect(disconnected_session_id, disconnect_type, trigger_disconnect_types, policy, orders)
  5. Fat-Finger Limit contract

    Blocks obviously erroneous orders on quantity, notional and aggressive price deviation. The last automated check between a mistyped order and a market-wide incident.

    fatFingerLimit(side, limit_price_atoms, reference_price_atoms, quantity, max_quantity, max_notional_atoms, max_aggressive_deviation_bps)
  6. Circuit-Breaker Trigger contract

    Evaluates market-wide circuit breaker levels against the index move. Levels are sequential — once a level has fired it cannot fire again the same session, which is why the previously-triggered level is an input.

    circuitBreakerTrigger(reference_close_atoms, current_index_atoms, level_thresholds_bps, previously_triggered_level)

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 { tickSizeValidation } from "fintech-algorithms/matching-engines-and-venue-logic/order-controls/tick-size-validation";
import { priceBandValidation } from "fintech-algorithms/matching-engines-and-venue-logic/order-controls/price-band-validation";

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.