1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Risk management module for position limits, exposure control, circuit breakers, and drawdown tracking.
//!
//! This module provides tools for managing risk in market making operations,
//! including position limits, notional exposure limits, order scaling,
//! circuit breakers, and drawdown monitoring.
//!
//! # Overview
//!
//! Market makers must carefully manage their inventory to avoid excessive
//! exposure to price movements. This module provides:
//!
//! - **Position Limits**: Maximum absolute position size (units)
//! - **Notional Limits**: Maximum exposure in currency terms
//! - **Order Scaling**: Automatic reduction of order sizes near limits
//! - **Circuit Breakers**: Automatic trading halts on adverse conditions
//! - **Drawdown Tracking**: Monitor and limit decline from peak equity
//! - **Alert System**: Configurable alerts for critical events
//! - **Portfolio Risk**: Correlation-aware multi-asset risk management
//!
//! # Example
//!
//! ```rust
//! use market_maker_rs::risk::{RiskLimits, DrawdownTracker, CircuitBreaker, CircuitBreakerConfig};
//! use market_maker_rs::dec;
//!
//! // Position limits
//! let limits = RiskLimits::new(
//! dec!(100.0), // max 100 units position
//! dec!(10000.0), // max $10,000 notional
//! dec!(0.5), // 50% scaling factor
//! ).unwrap();
//!
//! assert!(limits.check_order(dec!(50.0), dec!(10.0), dec!(100.0)).unwrap());
//!
//! // Circuit breaker
//! let config = CircuitBreakerConfig::new(
//! dec!(1000.0), dec!(0.05), 5, dec!(0.10), 300_000, 60_000
//! ).unwrap();
//! let breaker = CircuitBreaker::new(config);
//! assert!(breaker.is_trading_allowed());
//!
//! // Drawdown tracking
//! let mut tracker = DrawdownTracker::new(dec!(10000.0), dec!(0.20)).unwrap();
//! tracker.update(dec!(9000.0), 1000);
//! assert_eq!(tracker.current_drawdown(), dec!(0.1)); // 10% drawdown
//! ```
/// Alert system for critical event notification.
/// Portfolio risk management with correlation-aware calculations.
pub use ;
pub use ;
pub use ;
pub use RiskLimits;
pub use ;