Risk Limits (Deep Dive)¶
Risk limits are enforced by RiskManager and created by RiskFactory. Limits apply at order time and can also validate the portfolio state.
Limit Evaluation Diagram¶
flowchart LR
A[Order] --> B[RiskManager]
B --> C[Limits]
C --> D{All Pass?}
D -- Yes --> E[Execute]
D -- No --> F[Reject]
Limit Types¶
- MaxNotional:
limits.max_notionalcaps order notional. - MaxPosition:
limits.max_positioncaps absolute position size. - MaxPositionPct:
limits.max_position_pctcaps position value as a fraction of equity. - MaxDrawdown:
limits.max_drawdowncaps portfolio drawdown fraction. - MaxGrossExposure:
limits.max_gross_exposurecaps total absolute exposure. - MaxNetExposure:
limits.max_net_exposurecaps directional exposure. - MaxLeverage:
limits.max_leveragecaps leverage ratio.
Sector And Industry Limits¶
limits.sector_limitsmaps sector to max exposure pct.limits.sector_mapmaps symbol to sector.limits.industry_limitsmaps industry to max exposure pct.limits.industry_mapmaps symbol to industry.
Correlation Limit¶
limits.correlation.windowlength of the rolling price window.limits.correlation.max_corrcorrelation threshold.limits.correlation.max_pair_exposure_pctcap for correlated pair exposure.
Regime-Specific Limits¶
You can apply stricter limits in specific regimes:
risk:
limits:
max_position_pct: 0.2
limits_by_regime:
crisis:
limits:
max_position_pct: 0.05
max_notional: 25000
How Limits Are Evaluated¶
- Each limit produces
Okor a failure withError::Code::OutOfRange. - The risk manager aggregates all configured limits and rejects orders that violate any limit.