fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Minimum-Imbalance Tie-Break

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#

minimumImbalanceTieBreak(ordersRaw, referenceRaw, tickRaw)

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

Parameters#

NameTypeNotes
ordersRawOrder[]Auction orders.
referenceRawnumberReference price for further ties.
tickRawnumberTick 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#

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#

ordersRaw
[
  {
    "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
100
tickRaw
1

Call#

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

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

This module also 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.

Diagrams#

Minimum-Imbalance Tie-Break — system map

Calculation flow#

Minimum-Imbalance Tie-Break calculation flow
flowchart LR
    S1["Evaluate every candidate"]
    S2["Retain maximum executable volume"]
    S3["Calculate absolute imbalance for survivors"]
    S4["Retain minimumimbalance survivors"]
    S5["Return one price or an explicit remaining tie"]
    S1 --> S2
    S2 --> S3
    S3 --> S4
    S4 --> S5
    S5 --> D{"an unresolved tie after both objectives"}
    D --> O["selected_price + diagnostics"]
    O --> A["Audit: A nonmaximumvolume price can never win on imbalance"]

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.

Read the article →

References#

The rest of the Auctions family#