Risk Management¶
Risk in RegimeFlow is enforced by the RiskManager and optional stop-loss rules. Risk configuration is applied through BacktestEngine::configure_risk and the live engine's LiveConfig::risk_config.
Risk Limits¶
Risk limits are configured under limits.
Supported keys:
limits.max_notionalmaximum notional per order.limits.max_positionmaximum position size in shares/contracts.limits.max_position_pctmaximum position as a fraction of equity.limits.max_drawdownmaximum drawdown fraction.limits.max_gross_exposuremaximum gross exposure as a fraction of equity.limits.max_net_exposuremaximum net exposure as a fraction of equity.limits.max_leveragemaximum leverage.
Sector and industry limits:
limits.sector_limitsmap of sector to max exposure pct.limits.sector_mapmap of symbol to sector.limits.industry_limitsmap of industry to max exposure pct.limits.industry_mapmap of symbol to industry.
Correlation limits:
limits.correlation.windowprice history window length.limits.correlation.max_corrcorrelation threshold.limits.correlation.max_pair_exposure_pctmax exposure for correlated pairs.
Regime-specific limits:
limits_by_regime.<regime>.limits.*use the same keys as above, scoped to a regime label.
Regime-aware overlays:
RegimeRiskOverlayLimitreadsorder.metadata["regime"]and applies matching profiles.- A profile can block new exposure while still allowing risk-reducing orders.
- A profile can cap single-order notional and projected position notional as a fraction of equity.
- A profile can reduce execution aggression by blocking market-style orders or IOC/FOK time-in-force values.
Example:
risk:
limits:
max_notional: 100000
max_position_pct: 0.2
max_drawdown: 0.2
limits_by_regime:
crisis:
limits:
max_notional: 25000
max_position_pct: 0.05
Stop-Loss Configuration¶
Stop-loss rules are configured under stop_loss, trailing_stop, atr_stop, and time_stop:
stop_loss.enableandstop_loss.pctfor fixed stop loss.trailing_stop.enableandtrailing_stop.pctfor trailing stop loss.atr_stop.enable,atr_stop.window,atr_stop.multiplierfor ATR-based stops.time_stop.enable,time_stop.max_holding_secondsfor time-based exits.
Example:
risk:
limits:
max_position_pct: 0.2
stop_loss:
enable: true
pct: 0.05
trailing_stop:
enable: true
pct: 0.03
atr_stop:
enable: true
window: 14
multiplier: 2.0
time_stop:
enable: true
max_holding_seconds: 7200
Next Steps¶
guide/execution-models.mdreference/configuration.md
Regime Risk Overlays¶
RiskFactory can build compact regime-aware overlays from config. Orders opt into a profile by carrying order.metadata["regime"]. Live and backtest configs can use the same shape:
risk:
regime_overlays:
crisis:
allow_new_exposure: false
max_order_notional: 5000
max_position_pct: 0.05
allow_market_orders: false
allow_aggressive_tif: false
The same block is also accepted under risk.limits.regime_overlays for configs that keep all limit definitions under limits. Risk-reducing orders are still allowed when allow_new_exposure is false. Use allow_market_orders: false and allow_aggressive_tif: false to force passive/less urgent execution behavior in stressed regimes.