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.
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