fix(trading_service, ml): replace silently-mock allocation data with logged defaults
- allocation.rs: get_asset_volatilities now uses flat 0.20 (20% annual vol) instead of index-scaled 0.15+i*0.05; get_covariance_matrix diagonal is 0.04 (0.20^2) instead of 0.0225; get_ml_predictions uses 0.0 (neutral) instead of 0.05+i*0.02. All three emit tracing::warn so mock state is visible in production logs. - training.rs: train_all emits tracing::warn that it is using a placeholder loop and directs callers to use model-specific trainers for production. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -333,6 +333,9 @@ impl TrainingPipeline {
|
||||
|
||||
// SIMPLIFIED: Basic training loop - full implementation requires actual model training
|
||||
// TODO: Implement proper gradient descent, backpropagation, and loss calculation
|
||||
tracing::warn!(
|
||||
"train_all: using placeholder training loop. Use model-specific trainers for production."
|
||||
);
|
||||
for epoch in 0..self.config.epochs.min(3) {
|
||||
// Placeholder metrics - real implementation needs actual training
|
||||
let train_loss = 1.0 / (epoch as f64 + 1.0);
|
||||
|
||||
@@ -663,30 +663,33 @@ impl PortfolioAllocator {
|
||||
&self,
|
||||
assets: &[String],
|
||||
) -> Result<HashMap<String, f64>, CommonError> {
|
||||
// Mock data for now - in production, calculate from historical prices
|
||||
tracing::warn!(
|
||||
"get_asset_volatilities: using default values (not yet wired to market data)"
|
||||
);
|
||||
let mut volatilities = HashMap::new();
|
||||
for (i, symbol) in assets.iter().enumerate() {
|
||||
// Simulate different volatilities
|
||||
let vol = 0.15 + (i as f64 * 0.05);
|
||||
volatilities.insert(symbol.clone(), vol);
|
||||
for symbol in assets.iter() {
|
||||
// 20% annual volatility default — replace with historical calculation
|
||||
volatilities.insert(symbol.clone(), 0.20);
|
||||
}
|
||||
Ok(volatilities)
|
||||
}
|
||||
|
||||
/// Get covariance matrix for assets
|
||||
async fn get_covariance_matrix(&self, assets: &[String]) -> Result<Vec<Vec<f64>>, CommonError> {
|
||||
// Mock data - in production, calculate from historical returns
|
||||
tracing::warn!(
|
||||
"get_covariance_matrix: using default values (not yet wired to market data)"
|
||||
);
|
||||
let n = assets.len();
|
||||
let mut matrix = vec![vec![0.0; n]; n];
|
||||
|
||||
for i in 0..n {
|
||||
for j in 0..n {
|
||||
if i == j {
|
||||
// Variance on diagonal
|
||||
matrix[i][j] = 0.0225; // 15% vol squared
|
||||
// Variance on diagonal: 0.20^2 = 0.04
|
||||
matrix[i][j] = 0.04;
|
||||
} else {
|
||||
// Correlation off-diagonal
|
||||
matrix[i][j] = 0.01; // Low correlation
|
||||
// Low correlation off-diagonal
|
||||
matrix[i][j] = 0.01;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,11 +702,13 @@ impl PortfolioAllocator {
|
||||
&self,
|
||||
assets: &[String],
|
||||
) -> Result<HashMap<String, f64>, CommonError> {
|
||||
// Mock data - in production, call ML service
|
||||
tracing::warn!(
|
||||
"get_ml_predictions: using default values (not yet wired to market data)"
|
||||
);
|
||||
let mut predictions = HashMap::new();
|
||||
for (i, symbol) in assets.iter().enumerate() {
|
||||
let pred = 0.05 + (i as f64 * 0.02);
|
||||
predictions.insert(symbol.clone(), pred);
|
||||
for symbol in assets.iter() {
|
||||
// Neutral prediction — replace with actual ML inference
|
||||
predictions.insert(symbol.clone(), 0.0);
|
||||
}
|
||||
Ok(predictions)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user