remove dummy data, improve training , follow architecture
This commit is contained in:
@ -69,16 +69,13 @@ except ImportError:
|
||||
COB_INTEGRATION_AVAILABLE = False
|
||||
logger.warning("COB integration not available")
|
||||
|
||||
# Universal Data Stream - temporarily disabled due to import issues
|
||||
UNIFIED_STREAM_AVAILABLE = False
|
||||
|
||||
# Placeholder class for disabled Universal Data Stream
|
||||
class UnifiedDataStream:
|
||||
"""Placeholder for disabled Universal Data Stream"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
def register_consumer(self, *args, **kwargs):
|
||||
return "disabled"
|
||||
# Universal Data Adapter - the correct architecture implementation
|
||||
try:
|
||||
from core.universal_data_adapter import UniversalDataAdapter, UniversalDataStream
|
||||
UNIVERSAL_DATA_AVAILABLE = True
|
||||
except ImportError:
|
||||
UNIVERSAL_DATA_AVAILABLE = False
|
||||
logger.warning("Universal Data Adapter not available")
|
||||
|
||||
# Import RL COB trader for 1B parameter model integration
|
||||
from core.realtime_rl_cob_trader import RealtimeRLCOBTrader, PredictionResult
|
||||
@ -117,20 +114,13 @@ class CleanTradingDashboard:
|
||||
)
|
||||
self.component_manager = DashboardComponentManager()
|
||||
|
||||
# Initialize Universal Data Stream for the 5 timeseries architecture
|
||||
if UNIFIED_STREAM_AVAILABLE:
|
||||
self.unified_stream = UnifiedDataStream(self.data_provider, self.orchestrator)
|
||||
self.stream_consumer_id = self.unified_stream.register_consumer(
|
||||
consumer_name="CleanTradingDashboard",
|
||||
callback=self._handle_unified_stream_data,
|
||||
data_types=['ticks', 'ohlcv', 'training_data', 'ui_data']
|
||||
)
|
||||
logger.debug(f"Universal Data Stream initialized with consumer ID: {self.stream_consumer_id}")
|
||||
logger.debug("Subscribed to Universal 5 Timeseries: ETH(ticks,1m,1h,1d) + BTC(ticks)")
|
||||
# Initialize Universal Data Adapter access through orchestrator
|
||||
if UNIVERSAL_DATA_AVAILABLE:
|
||||
self.universal_adapter = UniversalDataAdapter(self.data_provider)
|
||||
logger.debug("Universal Data Adapter initialized - accessing data through orchestrator")
|
||||
else:
|
||||
self.unified_stream = None
|
||||
self.stream_consumer_id = None
|
||||
logger.warning("Universal Data Stream not available - fallback to direct data access")
|
||||
self.universal_adapter = None
|
||||
logger.warning("Universal Data Adapter not available - fallback to direct data access")
|
||||
|
||||
# Dashboard state
|
||||
self.recent_decisions: list = []
|
||||
@ -202,10 +192,8 @@ class CleanTradingDashboard:
|
||||
# Initialize unified orchestrator features - start async methods
|
||||
# self._initialize_unified_orchestrator_features() # Temporarily disabled
|
||||
|
||||
# Start Universal Data Stream
|
||||
if self.unified_stream:
|
||||
# threading.Thread(target=self._start_unified_stream, daemon=True).start() # Temporarily disabled
|
||||
logger.debug("Universal Data Stream starting...")
|
||||
# Universal Data Adapter is managed by orchestrator
|
||||
logger.debug("Universal Data Adapter ready for orchestrator data access")
|
||||
|
||||
# Initialize COB integration with high-frequency data handling
|
||||
self._initialize_cob_integration()
|
||||
@ -218,9 +206,19 @@ class CleanTradingDashboard:
|
||||
|
||||
logger.debug("Clean Trading Dashboard initialized with HIGH-FREQUENCY COB integration and signal generation")
|
||||
|
||||
def _handle_unified_stream_data(self, data):
|
||||
"""Placeholder for unified stream data handling."""
|
||||
logger.debug(f"Received data from unified stream: {data}")
|
||||
def _get_universal_data_from_orchestrator(self) -> Optional[UniversalDataStream]:
|
||||
"""Get universal data through orchestrator as per architecture."""
|
||||
try:
|
||||
if self.orchestrator and hasattr(self.orchestrator, 'get_universal_data_stream'):
|
||||
# Get data through orchestrator - this is the correct architecture pattern
|
||||
return self.orchestrator.get_universal_data_stream()
|
||||
elif self.universal_adapter:
|
||||
# Fallback to direct adapter access
|
||||
return self.universal_adapter.get_universal_data_stream()
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting universal data from orchestrator: {e}")
|
||||
return None
|
||||
|
||||
def _delayed_training_check(self):
|
||||
"""Check and start training after a delay to allow initialization"""
|
||||
@ -2187,10 +2185,10 @@ class CleanTradingDashboard:
|
||||
'parameters': 46000000, # ~46M params for transformer
|
||||
'last_prediction': transformer_last_prediction,
|
||||
'loss_5ma': transformer_state.get('current_loss', 0.0123),
|
||||
'initial_loss': transformer_state.get('initial_loss', 0.2980),
|
||||
'initial_loss': transformer_state.get('initial_loss'),
|
||||
'best_loss': transformer_state.get('best_loss', 0.0089),
|
||||
'improvement': safe_improvement_calc(
|
||||
transformer_state.get('initial_loss', 0.2980),
|
||||
transformer_state.get('initial_loss'),
|
||||
transformer_state.get('current_loss', 0.0123),
|
||||
95.9 # Default improvement percentage
|
||||
),
|
||||
@ -2227,10 +2225,10 @@ class CleanTradingDashboard:
|
||||
'confidence': 0.82
|
||||
},
|
||||
'loss_5ma': transformer_state.get('current_loss', 0.0156),
|
||||
'initial_loss': transformer_state.get('initial_loss', 0.3450),
|
||||
'initial_loss': transformer_state.get('initial_loss'),
|
||||
'best_loss': transformer_state.get('best_loss', 0.0098),
|
||||
'improvement': safe_improvement_calc(
|
||||
transformer_state.get('initial_loss', 0.3450),
|
||||
transformer_state.get('initial_loss'),
|
||||
transformer_state.get('current_loss', 0.0156),
|
||||
95.5 # Default improvement percentage
|
||||
),
|
||||
@ -2270,10 +2268,10 @@ class CleanTradingDashboard:
|
||||
'confidence': 0.74
|
||||
},
|
||||
'loss_5ma': cob_state.get('current_loss', 0.0098),
|
||||
'initial_loss': cob_state.get('initial_loss', 0.3560),
|
||||
'initial_loss': cob_state.get('initial_loss'),
|
||||
'best_loss': cob_state.get('best_loss', 0.0076),
|
||||
'improvement': safe_improvement_calc(
|
||||
cob_state.get('initial_loss', 0.3560),
|
||||
cob_state.get('initial_loss'),
|
||||
cob_state.get('current_loss', 0.0098),
|
||||
97.2 # Default improvement percentage
|
||||
),
|
||||
@ -2307,10 +2305,10 @@ class CleanTradingDashboard:
|
||||
'confidence': 0.78
|
||||
},
|
||||
'loss_5ma': decision_state.get('current_loss', 0.0089),
|
||||
'initial_loss': decision_state.get('initial_loss', 0.2980),
|
||||
'initial_loss': decision_state.get('initial_loss'),
|
||||
'best_loss': decision_state.get('best_loss', 0.0065),
|
||||
'improvement': safe_improvement_calc(
|
||||
decision_state.get('initial_loss', 0.2980),
|
||||
decision_state.get('initial_loss'),
|
||||
decision_state.get('current_loss', 0.0089),
|
||||
97.0 # Default improvement percentage
|
||||
),
|
||||
@ -5058,125 +5056,35 @@ class CleanTradingDashboard:
|
||||
logger.error(f"Error updating session metrics: {e}")
|
||||
|
||||
def _start_actual_training_if_needed(self):
|
||||
"""Start actual model training with real data collection and training loops"""
|
||||
"""Connect to centralized training system in orchestrator (following architecture)"""
|
||||
try:
|
||||
if not self.orchestrator:
|
||||
logger.warning("No orchestrator available for training")
|
||||
logger.warning("No orchestrator available for training connection")
|
||||
return
|
||||
logger.info("TRAINING: Starting actual training system with real data collection")
|
||||
self._start_real_training_system()
|
||||
logger.info("DASHBOARD: Connected to orchestrator's centralized training system")
|
||||
# Dashboard only displays training status - actual training happens in orchestrator
|
||||
# Training is centralized in the orchestrator as per architecture design
|
||||
except Exception as e:
|
||||
logger.error(f"Error starting comprehensive training system: {e}")
|
||||
logger.error(f"Error connecting to centralized training system: {e}")
|
||||
|
||||
def _start_real_training_system(self):
|
||||
"""Start real training system with data collection and actual model training"""
|
||||
"""ARCHITECTURE COMPLIANCE: Training moved to orchestrator - this is now a stub"""
|
||||
try:
|
||||
def training_coordinator():
|
||||
logger.info("TRAINING: High-frequency training coordinator started")
|
||||
training_iteration = 0
|
||||
last_dqn_training = 0
|
||||
last_cnn_training = 0
|
||||
last_decision_training = 0
|
||||
last_cob_rl_training = 0
|
||||
|
||||
# Performance tracking
|
||||
# Initialize performance tracking for display purposes only
|
||||
self.training_performance = {
|
||||
'decision': {'inference_times': [], 'training_times': [], 'total_calls': 0},
|
||||
'cob_rl': {'inference_times': [], 'training_times': [], 'total_calls': 0},
|
||||
'dqn': {'inference_times': [], 'training_times': [], 'total_calls': 0},
|
||||
'cnn': {'inference_times': [], 'training_times': [], 'total_calls': 0}
|
||||
'cnn': {'inference_times': [], 'training_times': [], 'total_calls': 0},
|
||||
'transformer': {'training_times': [], 'total_calls': 0}
|
||||
}
|
||||
|
||||
while True:
|
||||
try:
|
||||
training_iteration += 1
|
||||
current_time = time.time()
|
||||
market_data = self._collect_training_data()
|
||||
# Training is now handled by the orchestrator using TrainingIntegration
|
||||
# Dashboard only monitors and displays training status from orchestrator
|
||||
logger.info("DASHBOARD: Monitoring orchestrator's centralized training system")
|
||||
|
||||
if market_data:
|
||||
logger.debug(f"TRAINING: Collected {len(market_data)} market data points for training")
|
||||
|
||||
# High-frequency training for split-second decisions
|
||||
# Train decision fusion and COB RL as fast as hardware allows
|
||||
if current_time - last_decision_training > 0.1: # Every 100ms
|
||||
start_time = time.time()
|
||||
self._perform_real_decision_training(market_data)
|
||||
training_time = time.time() - start_time
|
||||
self.training_performance['decision']['training_times'].append(training_time)
|
||||
self.training_performance['decision']['total_calls'] += 1
|
||||
last_decision_training = current_time
|
||||
|
||||
# Keep only last 100 measurements
|
||||
if len(self.training_performance['decision']['training_times']) > 100:
|
||||
self.training_performance['decision']['training_times'] = self.training_performance['decision']['training_times'][-100:]
|
||||
|
||||
# Advanced Transformer Training (every 200ms for comprehensive features)
|
||||
if current_time - last_cob_rl_training > 0.2: # Every 200ms for transformer
|
||||
start_time = time.time()
|
||||
self._perform_real_transformer_training(market_data)
|
||||
training_time = time.time() - start_time
|
||||
if 'transformer' not in self.training_performance:
|
||||
self.training_performance['transformer'] = {'training_times': [], 'total_calls': 0}
|
||||
self.training_performance['transformer']['training_times'].append(training_time)
|
||||
self.training_performance['transformer']['total_calls'] += 1
|
||||
|
||||
# Keep only last 100 measurements
|
||||
if len(self.training_performance['transformer']['training_times']) > 100:
|
||||
self.training_performance['transformer']['training_times'] = self.training_performance['transformer']['training_times'][-100:]
|
||||
|
||||
if current_time - last_cob_rl_training > 0.1: # Every 100ms
|
||||
start_time = time.time()
|
||||
self._perform_real_cob_rl_training(market_data)
|
||||
training_time = time.time() - start_time
|
||||
self.training_performance['cob_rl']['training_times'].append(training_time)
|
||||
self.training_performance['cob_rl']['total_calls'] += 1
|
||||
last_cob_rl_training = current_time
|
||||
|
||||
# Keep only last 100 measurements
|
||||
if len(self.training_performance['cob_rl']['training_times']) > 100:
|
||||
self.training_performance['cob_rl']['training_times'] = self.training_performance['cob_rl']['training_times'][-100:]
|
||||
|
||||
# Standard frequency for larger models
|
||||
if current_time - last_dqn_training > 30:
|
||||
start_time = time.time()
|
||||
self._perform_real_dqn_training(market_data)
|
||||
training_time = time.time() - start_time
|
||||
self.training_performance['dqn']['training_times'].append(training_time)
|
||||
self.training_performance['dqn']['total_calls'] += 1
|
||||
last_dqn_training = current_time
|
||||
|
||||
if len(self.training_performance['dqn']['training_times']) > 50:
|
||||
self.training_performance['dqn']['training_times'] = self.training_performance['dqn']['training_times'][-50:]
|
||||
|
||||
if current_time - last_cnn_training > 45:
|
||||
start_time = time.time()
|
||||
self._perform_real_cnn_training(market_data)
|
||||
training_time = time.time() - start_time
|
||||
self.training_performance['cnn']['training_times'].append(training_time)
|
||||
self.training_performance['cnn']['total_calls'] += 1
|
||||
last_cnn_training = current_time
|
||||
|
||||
if len(self.training_performance['cnn']['training_times']) > 50:
|
||||
self.training_performance['cnn']['training_times'] = self.training_performance['cnn']['training_times'][-50:]
|
||||
|
||||
self._update_training_progress(training_iteration)
|
||||
|
||||
# Log performance metrics every 100 iterations
|
||||
if training_iteration % 100 == 0:
|
||||
self._log_training_performance()
|
||||
logger.info(f"TRAINING: Iteration {training_iteration} - High-frequency training active")
|
||||
|
||||
# Minimal sleep for maximum responsiveness
|
||||
time.sleep(0.05) # 50ms sleep for 20Hz training loop
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"TRAINING: Error in training iteration {training_iteration}: {e}")
|
||||
time.sleep(1) # Shorter error recovery
|
||||
training_thread = threading.Thread(target=training_coordinator, daemon=True)
|
||||
training_thread.start()
|
||||
logger.info("TRAINING: Real training system started successfully")
|
||||
except Exception as e:
|
||||
logger.error(f"Error starting real training system: {e}")
|
||||
logger.error(f"Error initializing training monitoring: {e}")
|
||||
|
||||
def _collect_training_data(self) -> List[Dict]:
|
||||
"""Collect real market data for training"""
|
||||
|
Reference in New Issue
Block a user