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 classification is continuous and real-time. The engine also tracks regime duration, which feeds into the time-decay function for margin transitions.
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 correlation component uses the same correlation structure: The final maintenance margin adds a per-position reserve for liquidation cost not already represented by impact: The reserve has a market-specific floor and scales with closeout impact. See Margin for the complete calculation.Marginal Contributions
For each position, the engine computes partial derivatives: This tells the liquidation optimizer how much each position contributes to overall portfolio risk. Candidate reductions also include their change in liquidation reserve, so correlation benefit and closeout cost both affect selection. See Liquidations for the full optimizer algorithm.Cascade Adjustment
The system incorporates liquidation impact feedback into margin and equity. It maintains size-indexed curves for:- Current cost of sweeping the closing side of the book
- Additional cost if the resulting move triggers nearby liquidation levels
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 impact-adjusted closeout equity falls below while mark-price position PnL is negative
Comparison to Existing Systems
See Margin, Liquidations, and Portfolio Margining for detailed specifications.