dash and training wip

This commit is contained in:
Dobromir Popov
2025-09-02 15:30:05 +03:00
parent 443e8e746f
commit 1b54438082
14 changed files with 270 additions and 197 deletions

View File

@@ -642,6 +642,35 @@ class CleanTradingDashboard:
logger.error(f"Error updating trades table: {e}")
return html.P(f"Error: {str(e)}", className="text-danger")
@self.app.callback(
Output('training-status', 'children'),
[Input('start-training-btn', 'n_clicks'),
Input('stop-training-btn', 'n_clicks')],
prevent_initial_call=True
)
def control_training(start_clicks, stop_clicks):
try:
from utils.training_integration import get_unified_training_manager
manager = get_unified_training_manager(
orchestrator=self.orchestrator,
data_provider=self.data_provider,
dashboard=self
)
ctx = dash.callback_context
if not ctx.triggered:
raise PreventUpdate
trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
if trigger_id == 'start-training-btn':
ok = manager.start()
return 'Running' if ok else 'Error'
elif trigger_id == 'stop-training-btn':
ok = manager.stop()
return 'Stopped' if ok else 'Error'
return 'Idle'
except Exception as e:
logger.error(f"Training control error: {e}")
return 'Error'
@self.app.callback(
[Output('eth-cob-content', 'children'),
Output('btc-cob-content', 'children')],
@@ -5215,7 +5244,12 @@ class CleanTradingDashboard:
"""Start the Dash server"""
try:
logger.info(f"TRADING: Starting Clean Dashboard at http://{host}:{port}")
self.app.run(host=host, port=port, debug=debug)
# Run the Dash app normally; launch/activation is handled by the runner
if hasattr(self, 'app') and self.app is not None:
# Dash 3.x: use app.run
self.app.run(host=host, port=port, debug=debug)
else:
logger.error("Dash app is not initialized")
except Exception as e:
logger.error(f"Error starting dashboard server: {e}")
raise

View File

@@ -153,6 +153,29 @@ class DashboardLayoutManager:
tooltip={"placement": "bottom", "always_visible": False}
)
], className="mb-2"),
# Training Controls
html.Div([
html.Label([
html.I(className="fas fa-play me-1"),
"Training Controls"
], className="form-label small mb-1"),
html.Div([
html.Button([
html.I(className="fas fa-play me-1"),
"Start Training"
], id="start-training-btn", className="btn btn-success btn-sm me-2",
style={"fontSize": "10px", "padding": "2px 8px"}),
html.Button([
html.I(className="fas fa-stop me-1"),
"Stop Training"
], id="stop-training-btn", className="btn btn-danger btn-sm",
style={"fontSize": "10px", "padding": "2px 8px"})
], className="d-flex align-items-center mb-1"),
html.Div([
html.Span("Training:", className="small me-1"),
html.Span(id="training-status", children="Idle", className="badge bg-secondary small")
])
], className="mb-2"),
# Entry Aggressiveness Control
html.Div([