Price-Band Validation
Install and import
npm install fintech-algorithmsimport { priceBandValidation } from "fintech-algorithms/matching-engines-and-venue-logic/order-controls/price-band-validation";Signature
priceBandValidation(side, limit_price_atoms, lower_band_atoms, upper_band_atoms, band_as_of_ns, inclusive)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.
Parameters
| Name | Type | Notes |
|---|---|---|
side | "buy" | "sell" | Order side, which decides which bound binds. |
limit_price_atoms | number | Limit price in atoms. min: 0 · integer: true |
lower_band_atoms | number | Lower band in atoms. min: 0 · integer: true |
upper_band_atoms | number | Upper band in atoms. min: 0 · integer: true |
band_as_of_ns | number | Nanosecond timestamp the band was published, so a stale band is detectable. |
inclusive | boolean | Whether prices exactly on the band are accepted. |
Returns
{ valid, reason, band_as_of_ns, … }
The verdict with the band version applied.
Errors
- When the lower band exceeds the upper band — throws
Complexity: time O(1),
space O(1).
Worked example
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input
"buy"102000095000010500001200000000trueCall
priceBandValidation(side, limit_price_atoms, lower_band_atoms, upper_band_atoms, band_as_of_ns, inclusive)Returns
object with 12 fields: side, limit_price_atoms, lower_band_atoms, upper_band_atoms, band_as_of_ns, inclusive, valid, distance_from_lower_atoms, …
{
"side": "buy",
"limit_price_atoms": 1020000,
"lower_band_atoms": 950000,
"upper_band_atoms": 1050000,
"band_as_of_ns": 1200000000,
"inclusive": true,
"valid": true,
"distance_from_lower_atoms": 70000,
"distance_to_upper_atoms": 30000,
"violation_atoms": 0,
"reason": "inside-band",
"state": "accepted"
}Other exports
This module also exports
tickSizeValidation, selfTradePrevention, cancelOnDisconnect, fatFingerLimit, circuitBreakerTrigger, calculate. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams
How it works
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References
- Plan to Address Extraordinary Market Volatility — Limit Up-Limit Down Plan participants
- Evidence boundary