fix(risk): add account_id field to OrderInfo for per-account risk tracking
Per-account circuit breaker and daily loss tracking was never applied to real accounts because check_order() hardcoded "default". Added account_id field to OrderInfo with backward-compatible None fallback. Updated all construction sites across risk crate tests and integration tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2010,6 +2010,7 @@ mod tests {
|
||||
order_type: Some(OrderType::Limit),
|
||||
portfolio_id: Some("test_portfolio".to_string()),
|
||||
strategy_id: Some("test_strategy".to_string()),
|
||||
account_id: Some("test_account".to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,8 @@ pub struct OrderInfo {
|
||||
pub portfolio_id: Option<String>,
|
||||
/// Trading strategy generating this order (if applicable)
|
||||
pub strategy_id: Option<String>,
|
||||
/// Account ID for per-account risk tracking (None falls back to "default" with warning)
|
||||
pub account_id: Option<String>,
|
||||
}
|
||||
|
||||
/// Comprehensive Profit and Loss metrics for portfolio tracking
|
||||
|
||||
@@ -49,6 +49,7 @@ fn create_test_order(symbol: &str, quantity: f64, price: f64) -> OrderInfo {
|
||||
order_type: Some(OrderType::Market),
|
||||
portfolio_id: Some(TEST_PORTFOLIO_ID.to_string()),
|
||||
strategy_id: None,
|
||||
account_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,6 +320,7 @@ fn test_order_info_type_conversions() {
|
||||
order_type: Some(OrderType::Market),
|
||||
portfolio_id: Some(TEST_PORTFOLIO_ID.to_string()),
|
||||
strategy_id: None,
|
||||
account_id: None,
|
||||
};
|
||||
|
||||
assert_eq!(order.quantity, quantity);
|
||||
|
||||
Reference in New Issue
Block a user