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:
jgrusewski
2026-02-23 22:07:50 +01:00
parent 5fe0cf953c
commit bfe1b2ce2c
3 changed files with 5 additions and 0 deletions

View File

@@ -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()),
})
}

View File

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

View File

@@ -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);