# Risk Management Enhancement Plan ## Goal Align risk controls with production policy: configurable thresholds, historical performance feedback, and comprehensive metrics. ## Tasks 1. **Configuration Externalisation** - [ ] Move hard-coded limits (max position size, daily loss, profit threshold, gas caps) into config/environment. - [ ] Support per-market overrides (e.g., by token pair or exchange). 2. **Dynamic Scoring** - [ ] Revisit `calculateRiskScore`, `calculateConfidence`, `calculateProfitability` to include real-time volatility, slippage history, and order book depth. - [ ] Integrate historical trade outcomes (from database) to adjust thresholds dynamically. 3. **Circuit Breaker & Monitoring** - [ ] Ensure circuit breaker triggers persist across restarts and expose Prometheus metrics for activations. - [ ] Add alerting thresholds (e.g., consecutive failures, daily loss approaching limit). 4. **Testing** - [ ] Add integration tests verifying risk rejections for low profit, high slippage, excessive gas price with configurable values. - [ ] Include fuzz/property tests for risk-related calculations. 5. **Documentation** - [ ] Update `docs/5_development/CONFIGURATION.md` with risk knobs. - [ ] Provide runbook entries for adjusting risk parameters during incidents. ## References - `pkg/risk/manager.go` - `pkg/arbitrage/service.go` (risk integration) - `pkg/metrics` for monitoring hooks