# Capabilities

The Nekuti Matching Engine is a Central Limit Order Book (CLOB) implementation designed for high-performance cryptocurrency exchanges. This document provides a comprehensive overview of the engine's architecture, capabilities, and core features.

# Amplified Liquidity

The Nekuti matching engine supports multi-way matching between related instruments. This means that whenever an order is created on an instrument, it can match with orders on related markets, allowing liquidity to be amplified across all related instruments.

# Supported Instruments

# Instrument Types

The engine supports a comprehensive range of trading instruments:

  • Spot Instruments - Direct trading of cryptocurrency pairs
  • Futures Contracts
    • Inverse Futures
    • Perpetual Futures
    • Quanto Futures
  • Swaps
    • Term/Term calendar spreads
    • Perp/Term calendar spreads

# Settlement Types

Futures contracts can be settled in different currencies:

  • Base currency settled (Linear) - Settled in the base currency of the pair
  • Quote currency settled (Inverse) - Settled in the quote currency
  • Any other currency settled (Quanto) - Settled in a third currency

# Marking Methods

  • Fair-Price marking - Uses external price feeds for mark pricing
  • Last-Price marking - Uses the last traded price on the exchange
  • Perpetual Future funding - Regular funding cycles for perpetual contracts

# Order Types & Execution

# Supported Order Types

The engine provides native support for a comprehensive set of order types:

  • Market Orders

    • Execute immediately at the best available price
    • Support for Immediate-Or-Cancel (IOC)
    • Support for Fill-Or-Kill (FOK)
  • Limit Orders

    • Rest in the order book at a specified price
  • Stop Orders

    • Stop-Loss / Take-Profit functionality
    • Stop-Market: Triggers a market order when stop price is reached
    • Stop-Limit: Triggers a limit order when stop price is reached
    • Trigger types:
      • MarkedPrice - Trigger based on mark price
      • LastPrice - Trigger based on last traded price
      • IndexPrice - Trigger based on index price
      • LastWithinMark - Trigger based on last price within mark boundaries

# Time in Force Options

Control how long orders remain active:

  • GoodTillCancel (GTC) - Remains active until filled or cancelled
  • Day - Automatically cancelled at end of trading day
  • ImmediateOrCancel (IOC) - Fill immediately or cancel unfilled portion
  • FillOrKill (FOK) - Fill entire order immediately or cancel completely

# Fill Type Constraints

  • None [default] - Standard order execution
  • Reduce Only - Only reduces existing position, cannot increase or open new positions
  • Post Only - Guaranteed to add liquidity; rejected if would execute immediately
  • Close - Closes an existing position

# Visibility Types

  • Visible [default] - Full order quantity displayed in order book
  • Hidden - Order not displayed in order book
  • Iceberg - Only partial quantity visible, remainder hidden

# Order Management

  • Order amendments - Modify price and quantity of existing orders
  • Order cancellation - Cancel individual orders
  • CancelAll - Cancel all open orders for an account
  • CancelAllAfter (aka "Dead Man's Switch") - Automatically cancel all orders if no activity within timeframe

# Margin Trading & Risk Management

# Cross-Margin Architecture

  • Cross-margin provisioning - Margin shared across all instruments per account
  • Real-time margin tracking - Continuous monitoring of available margin
  • Sub-accounts - Support for account hierarchies with independent margin pools

# Initial Margin

initial_margin
/docs/initial_margin

Initial margin is the margin required for an order to be approved. While the order is in the order book, the initial margin requirement for this order is "locked", meaning that this quantity cannot be withdrawn from the asset balance nor can it be used to provide margin for another order or leveraged instrument.

For unleveraged spot trading:

  • Simply the amount of the base currency needed for the order (bought or sold)

For leveraged futures trading:

  • Notional value of the order in settlement currency ÷ maximum permitted leverage ratio
  • Existing positions lock up maintenance margin
  • Opposite positions do not offset in margin calculations (maximum of long/short stakes is used)
  • Positive unrealized P&L does not increase available balance

The engine rejects an order that would bring the overall margin requirement above the available balance.

# Risk Limits

Users can control their risk limits for each instrument. Higher risk limits can trigger increased margin requirements, subject to margin configuration. The engine rejects an order if it would result in the total risk on this instrument being higher than the current risk limit.

Risk limits are tiered with corresponding margin requirements at each level.

# Maintenance Margin & Liquidation

maintenance_margin
/docs/maintenance_margin/

Once the market moves past the price at which an account balance + unrealized losses equals the margin requirement, a liquidation workflow is triggered.

# Liquidation Strategy

The liquidation procedure is a multi-step process designed to restore account solvency while minimizing market impact. If, at any point the account becomes solvent, the process will terminate:

  1. Risk Limit Reduction - If the Risk Limit for any instrument can be lowered to reduce maintenance margin, the engine will automatically do so and check solvency

  2. Order Cancellation - Cancel all open orders and check if the account is solvent

  3. Position Closure - Close positions that can be liquidated on the exchange to bring the account back to solvency

  4. Insurance Fund Transfer - Transfer all remaining positions and balances to the insurance fund account (liquidation account)

The order in which instruments are liquidated is configurable via the Liquidation Strategy setting.

# Mark-Price Cap

The engine tracks account solvency in real-time using a configurable Mark Price. The Mark Price used for solvency calculations can be capped at the "first bankruptcy price" to prevent negative equity scenarios.

# Automated De-Leveraging (ADL)

Should the liquidation account become insolvent, the engine will automatically trigger an ADL workflow to socialize losses amongst active accounts on the exchange.

# Self-Match Detection

The engine automatically invokes a distinct workflow which nets opposing orders from the same beneficial owner to prevent them from trading against each other on the engine. This helps prevent wash trading and serves as a compliance and integrity safeguard.

self_match_detection
/docs/self_match_detection

# Fees & Settlements

# Flexible Fee Configuration

The engine supports sophisticated fee structures with multiple tiers:

  • Fee schedules - Define fee rates for different user tiers
  • Fee types - Different rates for:
    • Maker fees (orders that add liquidity)
    • Taker fees (orders that remove liquidity)
    • Hidden order fees
    • Iceberg fees (separate for hidden/visible portions)
    • Liquidation fees
  • Fee account - All fees are credited to a designated fees account

# Balance Management

  • Balance tracking - Real-time tracking of all asset balances per account
  • Withdrawal validation - Ensures sufficient free funds (excluding locked margin)
  • Deposit processing - Account creation via initial deposit
  • Sub-account support - Account hierarchies with linked ownership

# Performance & Reliability

# High Performance

  • 1 million+ orders per second - Processing capability on commodity hardware
  • Sub-millisecond latency - Expected 99.9% of the time
  • Low-latency optimization - Designed for high-frequency trading environments

# Deterministic Execution

  • Consistent outcomes - Orders executed in a predictable manner
  • Reproducible state - Exact state recovery through command replay
  • No race conditions - Single-threaded deterministic processing

# Persistence & Recovery

The command stream is persisted in a binary format in one or several pre-configured locations. When the application restarts, it reads and replays the existing command files in chronological order. This means that by the time the application is ready to accept new inputs, it is in the exact same state as when it previously exited.

Snapshotting:

  • Application generates state snapshots at pre-configured intervals
  • On restart, inflates state from latest snapshot before replaying subsequent commands
  • Greatly speeds up engine startup time
  • Generated in parallel by a secondary "read-model" to avoid stop-the-world events

# Security & Stability

  • Cyberattack resilience - User-facing components designed to withstand attacks
  • System stability - No compromise to stability under attack
  • Data protection - Internal implementations and customer data remain protected

# Operations

  • Exchange suspension/resumption - Controlled trading halts and restarts
  • Rate limits - Configurable limits on order submission rates
  • Internal balance audit - Automated verification of balance integrity
  • Exchange statistics - Real-time operational metrics

# API Integration

# Industry-Standard APIs

The Nekuti matching engine exposes fully authenticated RESTful and WebSocket APIs for integration into your infrastructure.

apis
/docs/apis

# Trading & Account Management APIs

  • Order submission - Create new orders with full parameter support
  • Order amendment - Modify price and quantity of existing orders
  • Order cancellation - Cancel individual or all orders
  • Open order query - Retrieve current open orders
  • Trade monitoring - Subscribe to trade executions
  • Position tracking - Real-time position updates

# Account Administration APIs

  • Deposit/Withdraw funds - Manage account balances
  • Margin tracking - Monitor available margin in real-time
  • Balance queries - View balances across all assets

# Exchange Administration APIs

  • Instrument configuration - Add and configure trading instruments
  • Fee configuration - Set fee schedules for maker, taker, and specialty orders
  • Liquidation configuration - Configure liquidation workflow and accounts
  • Risk management - Set risk-limit indexed margin requirements
  • Operational controls - Suspend/resume trading, configure rate limits
  • Monitoring - Access exchange statistics and audit functions

# Real-Time Subscriptions

  • Order book subscriptions - Live order book depth updates
  • Position subscriptions - Real-time position changes
  • Execution subscriptions - Immediate trade notifications
  • Client execution notifications - Compact JSON format for external distribution