dash fix wip

This commit is contained in:
Dobromir Popov
2025-09-09 03:59:06 +03:00
parent 2f51966fa8
commit 47d63fddfb

View File

@@ -1062,6 +1062,7 @@ class CleanTradingDashboard:
logger.error(f"Training status error: {e}") logger.error(f"Training status error: {e}")
return 'Error', 'badge bg-danger small' return 'Error', 'badge bg-danger small'
# Simple prediction tracking callback to test registration
@self.app.callback( @self.app.callback(
[Output('total-predictions-count', 'children'), [Output('total-predictions-count', 'children'),
Output('active-models-count', 'children'), Output('active-models-count', 'children'),
@@ -1075,60 +1076,49 @@ class CleanTradingDashboard:
Output('model-performance-chart', 'figure')], Output('model-performance-chart', 'figure')],
[Input('interval-component', 'n_intervals')] [Input('interval-component', 'n_intervals')]
) )
def update_prediction_tracking(n_intervals): def update_prediction_tracking_simple(n_intervals):
"""Update prediction tracking with REAL inference stats and performance""" """Simple prediction tracking callback to test registration"""
try: try:
# Get real model status and performance data # Return basic static values for testing
model_stats = self._get_real_model_performance_data()
# Calculate summary metrics
total_predictions = model_stats.get('total_predictions', 0)
active_models = model_stats.get('active_models', 0)
total_rewards = model_stats.get('total_rewards', 0.0)
recent_predictions = model_stats.get('recent_predictions', [])
# Calculate average confidence
avg_confidence = 0.0
if recent_predictions:
valid_confidences = [p.get('confidence', 0.0) for p in recent_predictions if p.get('confidence', 0.0) > 0]
if valid_confidences:
avg_confidence = sum(valid_confidences) / len(valid_confidences)
# Calculate trend information
predictions_trend = "↗️ Active" if total_predictions > 5 else "⏸️ Waiting"
models_status = "✅ Loaded" if active_models > 0 else "⚠️ Loading..."
confidence_trend = f"📈 {avg_confidence:.1%}" if avg_confidence > 0.5 else f"📉 {avg_confidence:.1%}"
rewards_trend = "💰 Profitable" if total_rewards > 0 else "📊 Learning"
# Create timeline chart with real prediction data
timeline_fig = self._create_prediction_timeline_chart(model_stats)
# Create performance chart with real model metrics
performance_fig = self._create_model_performance_chart(model_stats)
return (
str(total_predictions),
str(active_models),
f"{avg_confidence:.1%}",
f"{total_rewards:+.2f}",
predictions_trend,
models_status,
confidence_trend,
rewards_trend,
timeline_fig,
performance_fig
)
except Exception as e:
logger.error(f"Error updating prediction tracking: {e}")
# Return safe defaults
empty_fig = { empty_fig = {
'data': [], 'data': [],
'layout': { 'layout': {
'title': 'Dashboard Initializing...',
'template': 'plotly_dark', 'template': 'plotly_dark',
'height': 300, 'height': 300,
'annotations': [{ 'annotations': [{
'text': f'Error loading data: {str(e)[:50]}...', 'text': 'Loading model data...',
'xref': 'paper', 'yref': 'paper',
'x': 0.5, 'y': 0.5,
'showarrow': False,
'font': {'size': 16, 'color': 'gray'}
}]
}
}
return (
"Loading...",
"Checking...",
"0.0%",
"0.00",
"⏳ Initializing",
"🔄 Starting...",
"⏸️ Waiting",
"📊 Ready",
empty_fig,
empty_fig
)
except Exception as e:
logger.error(f"Error in simple prediction tracking: {e}")
empty_fig = {
'data': [],
'layout': {
'title': 'Error',
'template': 'plotly_dark',
'height': 300,
'annotations': [{
'text': f'Error: {str(e)[:30]}...',
'xref': 'paper', 'yref': 'paper', 'xref': 'paper', 'yref': 'paper',
'x': 0.5, 'y': 0.5, 'x': 0.5, 'y': 0.5,
'showarrow': False, 'showarrow': False,
@@ -1136,7 +1126,7 @@ class CleanTradingDashboard:
}] }]
} }
} }
return "0", "0", "0", "0.00", empty_fig, empty_fig return "Error", "Error", "0.0%", "0.00", "❌ Error", "❌ Error", "❌ Error", "❌ Error", empty_fig, empty_fig
def _get_real_model_performance_data(self) -> Dict[str, Any]: def _get_real_model_performance_data(self) -> Dict[str, Any]:
"""Get real model performance data from orchestrator""" """Get real model performance data from orchestrator"""