fintech-algorithms

Opening-Cross Price

Install and import

bash
npm install fintech-algorithms
ts
import { openingCrossPrice } from "fintech-algorithms/matching-engines-and-venue-logic/auctions/opening-cross-price";

Signature

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

NameTypeNotes
ordersOrder[]Orders entered into the opening auction.
previousClosenumberPrevious close, the reference for the final tie-break.
ticknumberTick size in atoms.
min: 1 · integer: true
lownumberLower bound of the permitted opening range.
highnumberUpper 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

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

orders
[
  {
    "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
100
tick
1
low
95
high
105

Call

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

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

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

Diagrams

Opening-Cross Price — system map

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