Move 17 library crates into crates/, CLI binary into bin/fxt, consolidate 10 test crates into testing/, split config crate from deployment config files. Root directory reduced from 38+ to ~17 directories. All Cargo.toml paths and build.rs proto refs updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.8 KiB
Rust
51 lines
1.8 KiB
Rust
//! # ML Microstructure Integration Module
|
|
//!
|
|
//! Orchestrates all advanced microstructure ML models for unified HFT alpha generation.
|
|
//! Provides a single interface for all models with ensemble prediction capabilities.
|
|
|
|
use std::collections::{HashMap, VecDeque};
|
|
use std::sync::Arc;
|
|
use std::sync::atomic::{AtomicU64, Ordering};
|
|
use std::time::Instant;
|
|
|
|
use candle_core::Device;
|
|
use candle_core::{Device, VarBuilder};
|
|
use serde::{Deserialize, Serialize};
|
|
use tokio::sync::{RwLock, Mutex};
|
|
|
|
use crate::{MLAppResult, InferenceResult, ModelMetadata};
|
|
use super::*;
|
|
use super::advanced_models::{
|
|
use super::advanced_models_extended::{
|
|
use super::{MarketDataUpdate, TradeDirection, MicrostructureResult};
|
|
|
|
#[tokio::test]
|
|
async fn test_ensemble_creation() {
|
|
let device = Device::Cpu;
|
|
let ensemble = MicrostructureMLEnsemble::new(device).await;
|
|
|
|
// Note: This will fail without proper model files, but tests the structure
|
|
assert!(ensemble.is_err()); // Expected without trained models
|
|
}
|
|
|
|
#[test]
|
|
fn test_ensemble_weights() {
|
|
let weights = EnsembleWeights::default();
|
|
let total_weight = weights.ofi_weight + weights.liquidity_weight +
|
|
weights.spread_weight + weights.impact_weight +
|
|
weights.toxicity_weight;
|
|
|
|
assert!((total_weight - 1.0).abs() < 0.01); // Should sum to approximately 1.0
|
|
}
|
|
|
|
#[test]
|
|
fn test_trading_action_determination() {
|
|
// Test various alpha/confidence combinations
|
|
let action_strong_buy = TradingAction::StrongBuy;
|
|
let action_hold = TradingAction::Hold;
|
|
|
|
// These would be tested with actual ensemble logic
|
|
assert!(matches!(action_strong_buy, TradingAction::StrongBuy));
|
|
assert!(matches!(action_hold, TradingAction::Hold));
|
|
}
|
|
} |