Pro-Rata Matching
Install and import
npm install fintech-algorithmsimport { proRataMatching } from "fintech-algorithms/matching-engines-and-venue-logic/continuous-matching/pro-rata-matching";Signature
proRataMatching(incomingRaw, priceRaw, lotRaw, restingRaw)Allocates a fill across all resting orders at a price in proportion to size, ignoring arrival time. Common in some futures markets, and it removes the incentive to queue that price-time creates — participants instead inflate size.
Parameters
| Name | Type | Notes |
|---|---|---|
incomingRaw | Order | The aggressing order. |
priceRaw | number | Price level at which allocation occurs. |
lotRaw | number | Lot size; allocations round to it, and the rounding remainder must be redistributed rather than lost. min: 1 · integer: true |
restingRaw | Order[] | Resting orders at that price. |
Returns
{ allocations, residual, remainder_handling, … }
Per-order allocation with how the rounding remainder was distributed.
Errors
- When lot size is not a positive integer — throws
Complexity: time O(resting),
space O(resting).
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
60010010[
{
"order_id": "R-1",
"side": "sell",
"price": 100,
"remaining_quantity": 500,
"arrival_sequence": 10
},
{
"order_id": "R-2",
"side": "sell",
"price": 100,
"remaining_quantity": 300,
"arrival_sequence": 20
},
{
"order_id": "R-3",
"side": "sell",
"price": 100,
"remaining_quantity": 200,
"arrival_sequence": 30
}
]Call
proRataMatching(incomingRaw, priceRaw, lotRaw, restingRaw)Returns
object with 9 fields: model, price, lot_size, incoming_quantity, executable_quantity, allocated_quantity, unfilled_quantity, allocations, …
{
"model": "single-price-lot-aware-pro-rata",
"price": 100,
"lot_size": 10,
"incoming_quantity": 600,
"executable_quantity": 600,
"allocated_quantity": 600,
"unfilled_quantity": 0,
"allocations": [
{
"order_id": "R-1",
"resting_quantity": 500,
"allocated_quantity": 300,
"remaining_quantity": 200,
"arrival_sequence": 10
},
{
"order_id": "R-2",
"resting_quantity": 300,
"allocated_quantity": 180,
"remaining_quantity": 120,
"arrival_sequence": 20
},
{
"order_id": "R-3",
"resting_quantity": 200,
"allocated_quantity": 120,
"remaining_quantity": 80,
"arrival_sequence": 30
}
],
"state": "fully-allocated"
}Other exports
This module also exports
priceTimePriority, sizeTimePriority, hybridProRataTime, 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
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.
References
- Matching principles — Eurex Frankfurt AG
- Matching Algorithm Overview — CME Group
- Evidence boundary