better logging

This commit is contained in:
Dobromir Popov
2025-09-09 09:41:30 +03:00
parent 47d63fddfb
commit 34780d62c7

View File

@@ -4326,11 +4326,11 @@ class CleanTradingDashboard:
# Safe logging with formatted values
try:
price_change_str = f"{price_change_pct:+.2%}" if abs(price_change_pct) < 10 else f"{price_change_pct:+.1f}"
logger.debug(f"💰 IMMEDIATE TRAINING: {symbol} {predicted_action} signal - "
logger.info(f"💰 IMMEDIATE TRAINING: {symbol} {predicted_action} signal - "
f"Price: {signal_price:.6f}{current_price:.6f} ({price_change_str}) - "
f"{'' if prediction_correct else ''} Correct - Reward: {final_reward:.2f}")
except Exception as e:
logger.debug(f"Error in training log for {symbol}: {e}")
logger.error(f"Error in training log for {symbol}: {e}")
except Exception as e:
logger.debug(f"Error in immediate price feedback training: {e}")
@@ -4832,7 +4832,7 @@ class CleanTradingDashboard:
logger.info(" 🔄 LOW REWARDS: May need reward scaling adjustment")
except Exception as e:
logger.debug(f"Error generating training performance report: {e}")
logger.warning(f"Error generating training performance report: {e}")
def _create_cob_features_from_inference_data(self, inference_data: Dict, signal_price: float) -> Optional[List[float]]:
"""Create COB features from stored inference data for better backpropagation"""
@@ -5047,7 +5047,7 @@ class CleanTradingDashboard:
# 5. Train Decision Fusion model
self._train_decision_fusion_on_signal(signal, trade_outcome)
logger.debug(f"Trained all models on {signal['action']} signal with outcome: {trade_outcome['pnl']:.2f}")
logger.info(f"COMPREHENSIVE TRAINING: All models trained on {signal['action']} signal with outcome: {trade_outcome['pnl']:.2f}")
except Exception as e:
logger.debug(f"Error training models on signal: {e}")
@@ -5130,7 +5130,7 @@ class CleanTradingDashboard:
if hasattr(self.orchestrator.rl_agent, 'replay'):
loss = self.orchestrator.rl_agent.replay(batch_size=32)
if loss is not None:
logger.debug(f"DQN trained on signal - loss: {loss:.4f}, reward: {reward:.2f}")
logger.info(f"DQN trained on signal - loss: {loss:.4f}, reward: {reward:.2f}")
except Exception as e:
logger.debug(f"Error training DQN on signal: {e}")
@@ -5233,7 +5233,7 @@ class CleanTradingDashboard:
if hasattr(self.orchestrator.cob_rl_agent, 'replay'):
loss = self.orchestrator.cob_rl_agent.replay(batch_size=32)
if loss is not None:
logger.debug(f"COB RL trained on signal - loss: {loss:.4f}, reward: {reward:.2f}")
logger.info(f"COB RL trained on signal - loss: {loss:.4f}, reward: {reward:.2f}")
except Exception as e:
logger.debug(f"Error training COB RL on signal: {e}")
@@ -6270,7 +6270,7 @@ class CleanTradingDashboard:
if not hasattr(self.orchestrator, 'recent_cnn_predictions'):
self.orchestrator.recent_cnn_predictions = {}
logger.debug("Enhanced training system initialized for model predictions")
logger.info("Enhanced training system initialized for model predictions")
except ImportError:
logger.warning("Enhanced training system not available - using mock predictions")
@@ -7740,7 +7740,7 @@ class CleanTradingDashboard:
if training_samples > 0:
avg_loss_info = f", avg_loss={total_loss/loss_count:.6f}" if loss_count > 0 else ""
performance_score = 100 / (1 + (total_loss/loss_count)) if loss_count > 0 else 0.1
logger.debug(f"DECISION TRAINING: Processed {training_samples} decision fusion samples{avg_loss_info}, perf_score={performance_score:.4f}")
logger.info(f"DECISION TRAINING: Processed {training_samples} decision fusion samples{avg_loss_info}, perf_score={performance_score:.4f}")
except Exception as e:
logger.error(f"Error in real decision fusion training: {e}")