Overview
BULK’s risk engine runs inline with the matching engine, evaluating every order and position change in real time. It is not a batch process or a background job - risk is assessed at the point of execution, before fills are confirmed. The engine is built on four interconnected systems: regime detection, lambda surfaces, portfolio margin, and cascade adjustment.Regime Detection
BULK classifies the current market environment into one of 9 regimes using a Hidden Markov Model. Each regime encodes direction and volatility:| Regime | Direction | Volatility |
|---|---|---|
| -12 | Bearish | High |
| -11 | Bearish | Medium |
| -10 | Bearish | Low |
| 0 | Neutral | Low |
| 1 | Neutral | Medium |
| 2 | Neutral | High |
| 10 | Bullish | Low |
| 11 | Bullish | Medium |
| 12 | Bullish | High |
Lambda Surfaces
Lambda () is BULK’s generalized risk parameter. Instead of static margin tiers, BULK uses lambda surfaces - continuous 3D functions that map to a maintenance margin rate: Each asset has its own lambda surface. The surface is interpolated bilinearly, meaning margin requirements change continuously as position size, leverage, or market conditions change - no discrete jumps at tier boundaries.Time Decay
When a regime change is detected, margin requirements don’t jump instantaneously. They follow a time-decay curve: Where is the rate at the time of the regime transition, is the new regime’s target, is the decay factor, and is time elapsed. This prevents unnecessary liquidation cascades from brief regime flickers. See Margin for the full regime table and how time decay works in practice.Portfolio Margin
For accounts with multiple positions, BULK computes a correlation-adjusted effective notional that captures diversification and hedging benefits.Effective Portfolio Notional
For each position , the signed notional is . The effective portfolio notional accounts for correlations: Where is the real-time correlation coefficient between assets and . When positions hedge each other (correlated assets, opposing directions), the cross terms become negative and shrinks well below the sum of individual notionals. Hedging discounts of up to 70% are achievable on correlated pairs.Portfolio Maintenance Margin
For each position, the signed margin component is: The portfolio maintenance margin uses the same correlation structure: This produces a single number that captures the true risk of the combined portfolio. See Margin for the step-by-step breakdown.Marginal Contributions
For each position, the engine computes partial derivatives: This tells the liquidation optimizer how much each position contributes to overall portfolio risk, enabling it to selectively reduce positions while preserving hedges. See Liquidations for the full optimizer algorithm.Cascade Adjustment
The system incorporates liquidation impact feedback into margin computation. When evaluating margin requirements, the engine estimates what would happen if positions needed to be unwound:- How much market impact would liquidating each position create?
- Would that impact cascade into further margin breaches for other accounts?
Background Risk Recomputation
In addition to inline risk checks at execution time, BULK runs background risk recomputation cycles that:- Update portfolio margins as mark prices change (even without new orders)
- Detect accounts approaching maintenance margin thresholds
- Trigger liquidation when equity falls below
Comparison to Existing Systems
| Feature | Static Tiers (most DEXs) | BULK Risk Engine | CME SPAN |
|---|---|---|---|
| Margin model | Fixed per-notional brackets | Continuous lambda surfaces | Scenario-based (16 scenarios) |
| Correlation | None | Full real-time matrix | Explicit inter-commodity spreads |
| Market regime | Ignored | 9 regimes, real-time HMM | Implied via stress scenarios |
| Margin transitions | Instant jumps | Smooth time-decay | Batch recomputation |
| Liquidation | Close biggest loser | Impact-ratio optimizer | Clearing house default management |
| Computation | Per-position | Portfolio-level | Portfolio-level |
| Latency | N/A (batch) | Inline with matching | Batch (typically overnight/intraday) |