Multi-Asset Trading Types
One type system across equities, options, futures, FX, bonds and digital assets, with 1:1 Go and TypeScript definitions
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
| Class | Module | Provider(s) |
|---|---|---|
| Equity | broker | Alpaca, IBKR, Apex |
| Option | broker | Alpaca, IBKR, Apex (4-leg max) |
| Future | futures | Apex Futures, IBKR |
| FX Pair | forex | CurrencyCloud, LMAX, Circle, OpenPayd |
| Bond | broker | IBKR |
| Digital Asset | exchange | On-chain (AMM / CLOB) |
Options
Strategy Templates (13 built-in)
| Strategy | Legs | Description |
|---|---|---|
| Long Call / Long Put | 1 | Directional |
| Covered Call / Protective Put | 2 | Hedged |
| Bull Call Spread / Bear Put Spread | 2 | Vertical |
| Straddle / Strangle | 2 | Volatility |
| Iron Condor | 4 | Range-bound |
| Iron Butterfly | 4 | Pinning |
| Calendar Spread | 2 | Time decay (per-leg expiration) |
| Diagonal Spread | 2 | Combined |
| Collar | 3 | Protection |
Approval Levels
| Level | Allowed Strategies |
|---|---|
| 1 | Covered calls, cash-secured puts |
| 2 | Level 1 + long calls/puts, debit spreads |
| 3 | Level 2 + credit spreads, iron condors |
| 4 | Level 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↔OptionContractGreeks(delta, gamma, theta, vega, rho, iv)StrategyLeg(with ratio field for ratio spreads)FuturesContract,FXPair,BondMarginRequirement,AccountMarginInstrument(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
- 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.
- 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.
Related LPs
- 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
Copyright and related rights waived via CC0.