fintech-algorithms

Fat-Finger Limit

Install and import

bash
npm install fintech-algorithms
ts
import { fatFingerLimit } from "fintech-algorithms/matching-engines-and-venue-logic/order-controls/fat-finger-limit";

Signature

fatFingerLimit(side, limit_price_atoms, reference_price_atoms, quantity, max_quantity, max_notional_atoms, max_aggressive_deviation_bps)

Blocks obviously erroneous orders on quantity, notional and aggressive price deviation. The last automated check between a mistyped order and a market-wide incident.

Parameters

NameTypeNotes
side"buy" | "sell"Order side.
limit_price_atomsnumberLimit price in atoms.
min: 0 · integer: true
reference_price_atomsnumberReference price the deviation is measured against.
min: 0 · integer: true
quantitynumberOrder quantity.
min: 0 · integer: true
max_quantitynumberMaximum permitted quantity.
min: 0 · integer: true
max_notional_atomsnumberMaximum permitted notional in atoms.
min: 0 · integer: true
max_aggressive_deviation_bpsnumberMaximum permitted aggressive deviation from the reference, in basis points.
min: 0 · integer: true

Returns

{ valid, breached_checks, quantity, notional, deviation_bps }

Which specific checks failed rather than a bare rejection — a participant cannot correct what they are not told.

Errors

  • When a limit is negative — throws

Complexity: time O(1), space O(1).

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

side
"buy"
limit_price_atoms
1015000
reference_price_atoms
1000000
quantity
4000
max_quantity
5000
max_notional_atoms
5000000000
max_aggressive_deviation_bps
200

Call

fatFingerLimit(side, limit_price_atoms, reference_price_atoms, quantity, max_quantity, max_notional_atoms, max_aggressive_deviation_bps)

Returns

object with 11 fields: side, limit_price_atoms, reference_price_atoms, quantity, order_notional_atoms, aggressive_deviation_bps, checks, violations, …

{
  "side": "buy",
  "limit_price_atoms": 1015000,
  "reference_price_atoms": 1000000,
  "quantity": 4000,
  "order_notional_atoms": 4060000000,
  "aggressive_deviation_bps": 150,
  "checks": {
    "quantity": {
      "value": 4000,
      "limit": 5000,
      "passed": true
    },
    "notional": {
      "value": 4060000000,
      "limit": 5000000000,
      "passed": true
    },
    "aggressive_deviation_bps": {
      "value": 150,
      "limit": 200,
      "passed": true
    }
  },
  "violations": [],
  "valid": true,
  "reason": "within-configured-limits",
  "state": "accepted"
}

Other exports

This module also exports tickSizeValidation, priceBandValidation, selfTradePrevention, cancelOnDisconnect, circuitBreakerTrigger, 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

Fat-Finger Limit — 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