This commit is contained in:
Dobromir Popov
2025-12-08 19:28:27 +02:00
parent 8263534b74
commit cf4808aa47
4 changed files with 226 additions and 82 deletions

View File

@@ -303,25 +303,48 @@ class TradingOrchestrator:
"""Initialize the enhanced orchestrator with full ML capabilities"""
self.config = get_config()
self.data_provider = data_provider or DataProvider()
self.universal_adapter = UniversalDataAdapter(self.data_provider)
# Temporarily disable UniversalDataAdapter to avoid crash
self.universal_adapter = None # UniversalDataAdapter(self.data_provider)
self.model_manager = None # Will be initialized later if needed
self.model_registry = model_registry # Model registry for dynamic model management
self.enhanced_rl_training = enhanced_rl_training
# Set primary trading symbol
self.symbol = self.config.get('primary_symbol', 'ETH/USDT')
self.ref_symbols = self.config.get('reference_symbols', ['BTC/USDT'])
# Initialize signal accumulator
self.signal_accumulator = {}
# Initialize confidence threshold
self.confidence_threshold = self.config.get('confidence_threshold', 0.6)
# CRITICAL: Initialize prediction tracking attributes FIRST to avoid attribute errors
# Model prediction tracking for dashboard visualization
self.recent_dqn_predictions: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Recent DQN predictions
self.recent_cnn_predictions: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Recent CNN predictions
self.recent_transformer_predictions: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Recent Transformer predictions
self.prediction_accuracy_history: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Prediction accuracy tracking
# Initialize prediction tracking for the primary trading symbol only
self.recent_dqn_predictions[self.symbol] = deque(maxlen=100)
self.recent_cnn_predictions[self.symbol] = deque(maxlen=50)
self.recent_transformer_predictions[self.symbol] = deque(maxlen=50)
self.prediction_accuracy_history[self.symbol] = deque(maxlen=200)
self.signal_accumulator[self.symbol] = []
# Determine the device to use from config.yaml
self.device = self._get_device_from_config()
logger.info(f"Using device: {self.device}")
def _get_device_from_config(self) -> torch.device:
"""Get device from config.yaml or auto-detect"""
try:
@@ -406,27 +429,6 @@ class TradingOrchestrator:
{}
) # {symbol: {side, size, entry_price, entry_time, pnl}}
self.trading_executor = None # Will be set by dashboard or external system
# Model prediction tracking for dashboard visualization
self.recent_dqn_predictions: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Recent DQN predictions
self.recent_cnn_predictions: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Recent CNN predictions
self.recent_transformer_predictions: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Recent Transformer predictions
self.prediction_accuracy_history: Dict[str, deque] = (
{}
) # {symbol: List[Dict]} - Prediction accuracy tracking
# Initialize prediction tracking for the primary trading symbol only
self.recent_dqn_predictions[self.symbol] = deque(maxlen=100)
self.recent_cnn_predictions[self.symbol] = deque(maxlen=50)
self.recent_transformer_predictions[self.symbol] = deque(maxlen=50)
self.prediction_accuracy_history[self.symbol] = deque(maxlen=200)
self.signal_accumulator[self.symbol] = []
# Decision callbacks
self.decision_callbacks: List[Any] = []