# Minimum-Imbalance Tie-Break

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

Full page: https://docs.thefintechbuilder.com/matching-engines-and-venue-logic/auctions/minimum-imbalance-tie-break/
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 { minimumImbalanceTieBreak } from "fintech-algorithms/matching-engines-and-venue-logic/auctions/minimum-imbalance-tie-break";
```

## Signature

```ts
minimumImbalanceTieBreak(ordersRaw, referenceRaw, tickRaw)
```

Applies the second auction criterion: among prices crossing equal volume, choose the one leaving the least unfilled imbalance.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `ordersRaw` | `Order[]` | yes | Auction orders. |
| `referenceRaw` | `number` | yes | Reference price for further ties. |
| `tickRaw` | `number` | yes | Tick size in atoms. · min: 1, integer: true |

## Returns

`{ price, imbalance, side, candidates, … }`

The selected price with the residual imbalance and which side it falls on.

## Errors

- When no candidate prices are supplied — throws

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

`ordersRaw`:

```json
[
  {
    "order_id": "B-101",
    "side": "buy",
    "order_type": "limit",
    "price": 101,
    "quantity": 500,
    "arrival_sequence": 10
  },
  {
    "order_id": "B-100",
    "side": "buy",
    "order_type": "limit",
    "price": 100,
    "quantity": 100,
    "arrival_sequence": 20
  },
  {
    "order_id": "S-099",
    "side": "sell",
    "order_type": "limit",
    "price": 99,
    "quantity": 100,
    "arrival_sequence": 30
  }
]
```

Showing 3 of 5 elements.

`referenceRaw`:

```json
100
```

`tickRaw`:

```json
1
```

### Call

```ts
minimumImbalanceTieBreak(ordersRaw, referenceRaw, tickRaw)
```

### Returns

object with 11 fields: model, reference_price, tick_size, order_count, maximum_executable_quantity, minimum_absolute_imbalance, volume_winner_prices, minimum_imbalance_prices, …

```json
{
  "model": "maximum-volume-then-minimum-imbalance",
  "reference_price": 100,
  "tick_size": 1,
  "order_count": 5,
  "maximum_executable_quantity": 500,
  "minimum_absolute_imbalance": 100,
  "volume_winner_prices": [100, 101],
  "minimum_imbalance_prices": [100],
  "selected_price": 100,
  "candidate_evaluations": [
    {
      "price": 99,
      "buy_quantity": 600,
      "sell_quantity": 100,
      "executable_quantity": 100,
      "imbalance_quantity": 500,
      "absolute_imbalance": 500,
      "imbalance_side": "buy"
    },
    {
      "price": 100,
      "buy_quantity": 600,
      "sell_quantity": 500,
      "executable_quantity": 500,
      "imbalance_quantity": 100,
      "absolute_imbalance": 100,
      "imbalance_side": "buy"
    },
    {
      "price": 101,
      "buy_quantity": 500,
      "sell_quantity": 700,
      "executable_quantity": 500,
      "imbalance_quantity": -200,
      "absolute_imbalance": 200,
      "imbalance_side": "sell"
    }
  ],
  "state": "tie-resolved"
}
```

## Other exports

`maximumExecutableVolumeAuction`, `openingCrossPrice`, `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/minimum-imbalance-tie-break/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/matching-engines-and-venue-logic/auctions/minimum-imbalance-tie-break/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
