LPsLux Proposals
DEX & Trading
LP-9029

Multi-Asset Trading Types

Final

One type system across equities, options, futures, FX, bonds and digital assets, with 1:1 Go and TypeScript definitions

Category
Interface
Created
2025-12-01

Abstract

This LP defines the unified type system used across all Lux trading modules. A single set of Go types in broker/pkg/types and TypeScript types in exchange/pkgs/options/src/types.ts ensures consistent representation of instruments across equities, options, futures, FX, and fixed income.

Motivation

A position is not a different thing because it is displayed in a different language. When the order router, the risk engine, the settlement path, and the UI each define their own OptionContract, the divergence shows up as a mispriced leg or a margin call that should not have happened. One definition, mirrored exactly in the two languages the stack is written in, removes that entire class of bug.

Specification

Instrument Classes

ClassModuleProvider(s)
EquitybrokerAlpaca, IBKR, Apex
OptionbrokerAlpaca, IBKR, Apex (4-leg max)
FuturefuturesApex Futures, IBKR
FX PairforexCurrencyCloud, LMAX, Circle, OpenPayd
BondbrokerIBKR
Digital AssetexchangeOn-chain (AMM / CLOB)

Options

Strategy Templates (13 built-in)

StrategyLegsDescription
Long Call / Long Put1Directional
Covered Call / Protective Put2Hedged
Bull Call Spread / Bear Put Spread2Vertical
Straddle / Strangle2Volatility
Iron Condor4Range-bound
Iron Butterfly4Pinning
Calendar Spread2Time decay (per-leg expiration)
Diagonal Spread2Combined
Collar3Protection

Approval Levels

LevelAllowed Strategies
1Covered calls, cash-secured puts
2Level 1 + long calls/puts, debit spreads
3Level 2 + credit spreads, iron condors
4Level 3 + naked options, ratio spreads

Margin

  • RegT (Alpaca): 50% initial, 25% maintenance for equities
  • SPAN (futures): risk-based margining per CME SPAN algorithm
  • Portfolio Margin: cross-asset netting (IBKR)

Type Alignment (Go ↔ TypeScript)

All Go types in broker/pkg/types/types.go have 1:1 TypeScript equivalents in exchange/pkgs/options/src/types.ts:

  • OptionContract ↔ OptionContract
  • Greeks (delta, gamma, theta, vega, rho, iv)
  • StrategyLeg (with ratio field for ratio spreads)
  • FuturesContract, FXPair, Bond
  • MarginRequirement, AccountMargin
  • Instrument (union type across all asset classes)

Rationale

Instrument is a union rather than a base class with per-asset subclasses, so adding an asset class cannot change the shape of the existing ones. Approval levels are a property of the account rather than the strategy template, which keeps the strategy catalogue purely descriptive and puts every permission decision in one place.

Security Considerations

  1. Type drift: the Go and TypeScript definitions MUST be kept in lockstep; a field present on one side and absent on the other silently drops data at the boundary. Round-trip tests over the union type are the check.
  2. Margin correctness: RegT, SPAN, and portfolio margin produce different requirements for the same position. The type carries which regime produced a MarginRequirement, so two regimes are never compared as if they were one.
  • LP-9028 — the engine these instruments trade on
  • LP-9206 — on-chain option series and settlement
  • LP-9205 / LP-9040 — perpetual futures

References

  • Lux research: lux-lightspeed-dex (multi-asset order matching), lux-perpetuals-derivatives (futures and options pricing), lux-credit-lending (margin lending), lux-restaking
  • Black-Scholes-Merton: options pricing model
  • SPAN: CME Standard Portfolio Analysis of Risk
  • Reg T: Federal Reserve Board margin requirements

Copyright and related rights waived via CC0.