# Opening-Cross Price

`D12-F02-A03` · 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/opening-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 { openingCrossPrice } from "fintech-algorithms/matching-engines-and-venue-logic/auctions/opening-cross-price";
```

## Signature

```ts
openingCrossPrice(orders, previousClose, tick, low, high)
```

Runs the full opening auction: maximum volume, minimum imbalance, then reference-price proximity, bounded by the permitted price range.

## Parameters

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

## Returns

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

The opening price and **which criterion decided it** — the audit trail an exchange has to be able to produce.

## 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": "MOO-B",
    "side": "buy",
    "order_type": "MOO",
    "price": null,
    "quantity": 200,
    "arrival_sequence": 10
  },
  {
    "order_id": "LOO-B101",
    "side": "buy",
    "order_type": "LOO",
    "price": 101,
    "quantity": 400,
    "arrival_sequence": 20
  },
  {
    "order_id": "LOO-B100",
    "side": "buy",
    "order_type": "LOO",
    "price": 100,
    "quantity": 300,
    "arrival_sequence": 30
  }
]
```

Showing 3 of 7 elements.

`previousClose`:

```json
100
```

`tick`:

```json
1
```

`low`:

```json
95
```

`high`:

```json
105
```

### Call

```ts
openingCrossPrice(orders, previousClose, 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-opening-cross",
  "session": "opening",
  "reference_price": 100,
  "collar_low": 95,
  "collar_high": 105,
  "eligible_order_count": 7,
  "selected_price": 100,
  "executed_quantity": 650,
  "buy_quantity": 900,
  "sell_quantity": 650,
  "imbalance_quantity": 250,
  "imbalance_side": "buy",
  "selection_trace": [
    "maximize executable quantity at 650",
    "minimize absolute imbalance at 250",
    "the objective hierarchy leaves one price"
  ],
  "candidate_evaluations": [
    {
      "price": 99,
      "buy_quantity": 900,
      "sell_quantity": 350,
      "executable_quantity": 350,
      "imbalance_quantity": 550,
      "absolute_imbalance": 550,
      "imbalance_side": "buy"
    },
    {
      "price": 100,
      "buy_quantity": 900,
      "sell_quantity": 650,
      "executable_quantity": 650,
      "imbalance_quantity": 250,
      "absolute_imbalance": 250,
      "imbalance_side": "buy"
    },
    {
      "price": 101,
      "buy_quantity": 600,
      "sell_quantity": 1150,
      "executable_quantity": 600,
      "imbalance_quantity": -550,
      "absolute_imbalance": 550,
      "imbalance_side": "sell"
    }
  ]
}
```

Showing 14 of 15 fields.

## Other exports

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