Wave 9 parallel agent deployment achieved successful compilation of: market-data, ml_training_service, backtesting, and risk packages. ## Wave 9: Multi-Package Test Fixes (4 Parallel Agents) **Agent 1 - market-data** (5 errors → 0) - Added rust_decimal_macros dev-dependency - Fixed BookSide vs OrderSide type confusion in tests - Changed OrderSide to BookSide for order book operations **Agent 2 - ml_training_service** (3 errors → 0) - Added tempfile dev-dependency for TempDir in tests - Fixed DatabaseConfig initialization: connect_timeout, query_timeout - Fixed MLConfig field access: model_config.model_type **Agent 3 - backtesting** (30 errors → 0) - Added missing imports: Order, OrderSide, OrderStatus, Position, Price, Quantity - Added rust_decimal_macros for dec! macro - Added num_traits::ToPrimitive trait - Fixed malformed match statements (lines 781-782, 880-881) - Added RiskSettings and FeatureSettings to public exports - Fixed Decimal type imports in test_ml_integration.rs **Agent 4 - risk** (32 errors → 0) - Removed non-existent common::basic and common::operations imports - Added FromPrimitive trait imports for Decimal conversions - Fixed Position struct initialization (added 9 missing fields) - Fixed ComplianceConfig initialization (market_abuse_threshold, large_exposure_threshold) - Fixed Order::new() calls (5 parameters instead of 4) - Fixed KillSwitch.activate() calls (added user_id and cascade params) - Changed log::error! to tracing::error! ## Summary ✅ market-data: COMPILES (0 errors) ✅ ml_training_service: COMPILES (0 errors) ✅ backtesting: COMPILES (0 errors) ✅ risk: COMPILES (0 errors) ✅ trading_engine: COMPILES (0 errors) ✅ trading_service: COMPILES (0 errors) Remaining: ml package (162 errors), tli examples/tests ## Files Modified - market-data/Cargo.toml - market-data/tests/basic_test.rs - services/ml_training_service/Cargo.toml - services/ml_training_service/src/database.rs - services/ml_training_service/src/main.rs - backtesting/src/lib.rs - backtesting/tests/test_ml_integration.rs - risk/src/operations.rs - risk/src/stress_tester.rs - risk/src/var_calculator/historical_simulation.rs - risk/src/var_calculator/monte_carlo.rs - risk/src/compliance.rs - risk/src/drawdown_monitor.rs - risk/src/safety/emergency_response.rs - risk/src/safety/safety_coordinator.rs - risk/src/safety/position_limiter.rs - risk/src/safety/trading_gate.rs
93 lines
2.5 KiB
Rust
93 lines
2.5 KiB
Rust
use chrono::Utc;
|
|
use market_data::{
|
|
error::MarketDataResult,
|
|
models::{IndicatorType, OrderBook, OrderBookLevelDb, BookSide, PriceRecord, TechnicalIndicator},
|
|
};
|
|
use rust_decimal_macros::dec;
|
|
use std::collections::HashMap;
|
|
|
|
#[test]
|
|
fn test_price_model() {
|
|
let mut price = PriceRecord::new("EURUSD".to_string(), Utc::now());
|
|
price.bid = Some(dec!(1.0850));
|
|
price.ask = Some(dec!(1.0852));
|
|
|
|
let mid = price.mid_price();
|
|
assert_eq!(mid, Some(dec!(1.0851)));
|
|
|
|
let spread = price.spread();
|
|
assert_eq!(spread, Some(dec!(0.0002)));
|
|
}
|
|
|
|
#[test]
|
|
fn test_order_book_model() {
|
|
let mut order_book = OrderBook::new("EURUSD".to_string(), Utc::now());
|
|
|
|
// Add some levels
|
|
let bid_level = OrderBookLevelDb::new(
|
|
"EURUSD".to_string(),
|
|
Utc::now(),
|
|
BookSide::Bid,
|
|
dec!(1.0850),
|
|
dec!(1000000),
|
|
0,
|
|
);
|
|
|
|
let ask_level = OrderBookLevelDb::new(
|
|
"EURUSD".to_string(),
|
|
Utc::now(),
|
|
BookSide::Ask,
|
|
dec!(1.0852),
|
|
dec!(1000000),
|
|
0,
|
|
);
|
|
|
|
order_book.bids.push(bid_level);
|
|
order_book.asks.push(ask_level);
|
|
|
|
assert_eq!(order_book.best_bid(), Some(dec!(1.0850)));
|
|
assert_eq!(order_book.best_ask(), Some(dec!(1.0852)));
|
|
assert_eq!(order_book.mid_price(), Some(dec!(1.0851)));
|
|
assert_eq!(order_book.spread(), Some(dec!(0.0002)));
|
|
}
|
|
|
|
#[test]
|
|
fn test_technical_indicator_model() {
|
|
let indicator = TechnicalIndicator::new(
|
|
"EURUSD".to_string(),
|
|
IndicatorType::Sma,
|
|
Utc::now(),
|
|
dec!(1.0851),
|
|
serde_json::json!({"period": 20}),
|
|
);
|
|
|
|
assert_eq!(indicator.symbol, "EURUSD");
|
|
assert_eq!(indicator.indicator_type, IndicatorType::Sma);
|
|
assert_eq!(indicator.value, dec!(1.0851));
|
|
}
|
|
|
|
#[test]
|
|
fn test_hash_traits() {
|
|
// Test BookSide is hashable
|
|
let mut side_map: HashMap<BookSide, i32> = HashMap::new();
|
|
side_map.insert(BookSide::Bid, 1);
|
|
side_map.insert(BookSide::Ask, 2);
|
|
|
|
assert_eq!(side_map.get(&BookSide::Bid), Some(&1));
|
|
assert_eq!(side_map.get(&BookSide::Ask), Some(&2));
|
|
|
|
// Test IndicatorType is hashable
|
|
let mut indicator_map: HashMap<IndicatorType, String> = HashMap::new();
|
|
indicator_map.insert(IndicatorType::Sma, "SMA".to_string());
|
|
indicator_map.insert(IndicatorType::Ema, "EMA".to_string());
|
|
|
|
assert_eq!(
|
|
indicator_map.get(&IndicatorType::Sma),
|
|
Some(&"SMA".to_string())
|
|
);
|
|
assert_eq!(
|
|
indicator_map.get(&IndicatorType::Ema),
|
|
Some(&"EMA".to_string())
|
|
);
|
|
}
|