How It Works
Calculator implements the portfolio margin formulas from Margin using risk surface data fetched live from the APIs. Risk surfaces: Fetches the full risk surface for every listed market viaGET /riskSurfaces. Each response contains all 9 regime surfaces (the complete 2D lambda grid of notional x leverage knots with mmrO, mmrE, p triplets), plus pair correlations and the asset’s current live regime. You can query this endpoint directly to build your own margin tooling.
Time decay: Each grid point contains three values. The effective lambda at time into the current regime is:
Where is the start-of-regime value, is the equilibrium value, and is the transition probability. The calculator uses the live regimeDt from the WebSocket ticker stream for time decay.
Live prices: Mark prices stream via WebSocket from the ticker and frontendContext subscriptions.
Correlation matrix: Pair correlations are returned by the risk surfaces endpoint. The correlation between assets and is , used in both the effective notional and portfolio margin calculations.
Regime sensitivity: The risk surfaces have a 2% floor for small positions. Regime differentiation in lambda values becomes visible at higher notional values (roughly $750k+ for BTC) and portfolio leverage (4-5x+). At these sizes, bear and bull regimes can produce significantly different margin requirements.
The margin calculation pipeline:
- Signed notional -
- Effective notional -
- Portfolio leverage -
- Lambda lookup - bilinear interpolation on the 2D surface (notional x leverage knots) with time decay
- Portfolio margin -