# Price-Band Validation

`D12-F03-A02` · Matching Engines and Venue Logic → Order Controls · archetype `record-transform` · difficulty 2/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/matching-engines-and-venue-logic/order-controls/price-band-validation/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { priceBandValidation } from "fintech-algorithms/matching-engines-and-venue-logic/order-controls/price-band-validation";
```

## Signature

```ts
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 | Required | Notes |
| --- | --- | --- | --- |
| `side` | `"buy" \| "sell"` | yes | Order side, which decides which bound binds. |
| `limit_price_atoms` | `number` | yes | Limit price in atoms. · min: 0, integer: true |
| `lower_band_atoms` | `number` | yes | Lower band in atoms. · min: 0, integer: true |
| `upper_band_atoms` | `number` | yes | Upper band in atoms. · min: 0, integer: true |
| `band_as_of_ns` | `number` | yes | Nanosecond timestamp the band was published, so a stale band is detectable. |
| `inclusive` | `boolean` | yes | 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

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

`side`:

```json
"buy"
```

`limit_price_atoms`:

```json
1020000
```

`lower_band_atoms`:

```json
950000
```

`upper_band_atoms`:

```json
1050000
```

`band_as_of_ns`:

```json
1200000000
```

`inclusive`:

```json
true
```

### Call

```ts
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, …

```json
{
  "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

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

## Verification and provenance

Tier: **verified** (via D).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/matching-engines-and-venue-logic/order-controls/price-band-validation/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/matching-engines-and-venue-logic/order-controls/price-band-validation/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/matching-engines-and-venue-logic/llms.txt
