start txt export from dash

This commit is contained in:
Dobromir Popov
2025-08-26 21:31:18 +03:00
parent b404191ffa
commit 300cf3eb2c
8 changed files with 239 additions and 59 deletions

View File

@@ -1921,6 +1921,86 @@ class CleanTradingDashboard:
logger.error(f"Error closing position manually: {e}")
return [html.I(className="fas fa-times me-1"), "CLOSE"]
# Text Export Controls
@self.app.callback(
Output('text-export-status', 'children'),
[Input('start-text-export-btn', 'n_clicks'),
Input('stop-text-export-btn', 'n_clicks')],
prevent_initial_call=True
)
def handle_text_export_controls(start_clicks, stop_clicks):
"""Handle text export start/stop buttons"""
ctx = dash.callback_context
if not ctx.triggered:
raise PreventUpdate
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
try:
if button_id == 'start-text-export-btn' and start_clicks:
success = self.orchestrator.start_text_export()
if success:
logger.info("Text export started from dashboard")
return "Export: Running"
else:
logger.error("Failed to start text export")
return "Export: Failed to start"
elif button_id == 'stop-text-export-btn' and stop_clicks:
success = self.orchestrator.stop_text_export()
if success:
logger.info("Text export stopped from dashboard")
return "Export: Stopped"
else:
logger.error("Failed to stop text export")
return "Export: Failed to stop"
except Exception as e:
logger.error(f"Error in text export controls: {e}")
return f"Export: Error - {str(e)}"
raise PreventUpdate
# LLM Proxy Controls
@self.app.callback(
Output('llm-status', 'children'),
[Input('start-llm-btn', 'n_clicks'),
Input('stop-llm-btn', 'n_clicks')],
prevent_initial_call=True
)
def handle_llm_controls(start_clicks, stop_clicks):
"""Handle LLM proxy start/stop buttons"""
ctx = dash.callback_context
if not ctx.triggered:
raise PreventUpdate
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
try:
if button_id == 'start-llm-btn' and start_clicks:
success = self.orchestrator.start_llm_proxy()
if success:
logger.info("LLM proxy started from dashboard")
return "LLM: Running"
else:
logger.error("Failed to start LLM proxy")
return "LLM: Failed to start"
elif button_id == 'stop-llm-btn' and stop_clicks:
success = self.orchestrator.stop_llm_proxy()
if success:
logger.info("LLM proxy stopped from dashboard")
return "LLM: Stopped"
else:
logger.error("Failed to stop LLM proxy")
return "LLM: Failed to stop"
except Exception as e:
logger.error(f"Error in LLM controls: {e}")
return f"LLM: Error - {str(e)}"
raise PreventUpdate
# Leverage slider callback
@self.app.callback(
Output('leverage-display', 'children'),

View File

@@ -320,6 +320,33 @@ class DashboardLayoutManager:
html.I(className="fas fa-arrows-rotate me-1"),
"Sync Positions/Orders"
], id="manual-sync-btn", className="btn btn-primary btn-sm w-100 mt-2"),
# Text Export Controls
html.Hr(className="my-2"),
html.Small("Text Export & LLM", className="text-muted d-block mb-1"),
html.Div([
html.Button([
html.I(className="fas fa-file-export me-1"),
"Start Text Export"
], id="start-text-export-btn", className="btn btn-success btn-sm me-1", style={"fontSize": "10px"}),
html.Button([
html.I(className="fas fa-stop me-1"),
"Stop"
], id="stop-text-export-btn", className="btn btn-danger btn-sm", style={"fontSize": "10px"})
], className="d-flex mb-2"),
html.Div([
html.Button([
html.I(className="fas fa-robot me-1"),
"Start LLM"
], id="start-llm-btn", className="btn btn-info btn-sm me-1", style={"fontSize": "10px"}),
html.Button([
html.I(className="fas fa-stop me-1"),
"Stop"
], id="stop-llm-btn", className="btn btn-warning btn-sm", style={"fontSize": "10px"})
], className="d-flex mb-2"),
html.Small(id="text-export-status", children="Export: Stopped", className="text-muted d-block"),
html.Small(id="llm-status", children="LLM: Stopped", className="text-muted d-block"),
html.Hr(className="my-2"),
html.Small("System Status", className="text-muted d-block mb-1"),
html.Div([