# Closing-Cross Price

`D12-F02-A04` · Matching Engines and Venue Logic → Auctions · archetype `record-transform` · difficulty 5/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/matching-engines-and-venue-logic/auctions/closing-cross-price/
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 { closingCrossPrice } from "fintech-algorithms/matching-engines-and-venue-logic/auctions/closing-cross-price";
```

## Signature

```ts
closingCrossPrice(orders, reference, tick, low, high)
```

The closing auction, which sets the price index funds actually trade at. Same criteria as the open, different reference and typically a tighter permitted band.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `orders` | `Order[]` | yes | Orders entered into the closing auction. |
| `reference` | `number` | yes | Reference price for tie-breaking. |
| `tick` | `number` | yes | Tick size in atoms. · min: 1, integer: true |
| `low` | `number` | yes | Lower bound of the permitted range. |
| `high` | `number` | yes | Upper bound. |

## Returns

`{ price, volume, imbalance, criterion_applied, … }`

The closing price with the deciding criterion.

## Errors

- When low exceeds high, or no order crosses — reported as a status rather than thrown

## Complexity

Time `O(orders log orders)`, space `O(prices)`.

## 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

`orders`:

```json
[
  {
    "order_id": "MOC-B",
    "side": "buy",
    "order_type": "MOC",
    "price": null,
    "quantity": 300,
    "arrival_sequence": 10
  },
  {
    "order_id": "LOC-B101",
    "side": "buy",
    "order_type": "LOC",
    "price": 101,
    "quantity": 350,
    "arrival_sequence": 20
  },
  {
    "order_id": "DAY-B100",
    "side": "buy",
    "order_type": "DAY",
    "price": 100,
    "quantity": 250,
    "arrival_sequence": 30
  }
]
```

Showing 3 of 7 elements.

`reference`:

```json
100
```

`tick`:

```json
1
```

`low`:

```json
95
```

`high`:

```json
105
```

### Call

```ts
closingCrossPrice(orders, reference, tick, low, high)
```

### Returns

object with 15 fields: model, session, reference_price, collar_low, collar_high, eligible_order_count, selected_price, executed_quantity, …

```json
{
  "model": "declared-closing-cross",
  "session": "closing",
  "reference_price": 100,
  "collar_low": 95,
  "collar_high": 105,
  "eligible_order_count": 7,
  "selected_price": 100,
  "executed_quantity": 700,
  "buy_quantity": 900,
  "sell_quantity": 700,
  "imbalance_quantity": 200,
  "imbalance_side": "buy",
  "selection_trace": [
    "maximize executable quantity at 700",
    "minimize absolute imbalance at 200",
    "the objective hierarchy leaves one price"
  ],
  "candidate_evaluations": [
    {
      "price": 99,
      "buy_quantity": 900,
      "sell_quantity": 400,
      "executable_quantity": 400,
      "imbalance_quantity": 500,
      "absolute_imbalance": 500,
      "imbalance_side": "buy"
    },
    {
      "price": 100,
      "buy_quantity": 900,
      "sell_quantity": 700,
      "executable_quantity": 700,
      "imbalance_quantity": 200,
      "absolute_imbalance": 200,
      "imbalance_side": "buy"
    },
    {
      "price": 101,
      "buy_quantity": 650,
      "sell_quantity": 1150,
      "executable_quantity": 650,
      "imbalance_quantity": -500,
      "absolute_imbalance": 500,
      "imbalance_side": "sell"
    }
  ]
}
```

Showing 14 of 15 fields.

## Other exports

`maximumExecutableVolumeAuction`, `minimumImbalanceTieBreak`, `openingCrossPrice`, `volatilityAuctionReopening`, `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/auctions/closing-cross-price/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/matching-engines-and-venue-logic/auctions/closing-cross-price/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
