73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
|
|
"""
|
||
|
|
Main dashboard application module.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import dash
|
||
|
|
from dash import html, dcc
|
||
|
|
from utils.logger import get_logger
|
||
|
|
from dashboard.layouts import (
|
||
|
|
get_market_data_layout,
|
||
|
|
get_bot_management_layout,
|
||
|
|
get_performance_layout,
|
||
|
|
get_system_health_layout
|
||
|
|
)
|
||
|
|
from dashboard.components import create_indicator_modal
|
||
|
|
|
||
|
|
logger = get_logger("dashboard_app")
|
||
|
|
|
||
|
|
|
||
|
|
def create_app():
|
||
|
|
"""Create and configure the Dash application."""
|
||
|
|
# Initialize Dash app
|
||
|
|
app = dash.Dash(__name__, suppress_callback_exceptions=True)
|
||
|
|
|
||
|
|
# Define the main layout
|
||
|
|
app.layout = html.Div([
|
||
|
|
# Page title
|
||
|
|
html.H1("🚀 Crypto Trading Bot Dashboard",
|
||
|
|
style={'text-align': 'center', 'color': '#2c3e50', 'margin-bottom': '30px'}),
|
||
|
|
|
||
|
|
# Navigation tabs
|
||
|
|
dcc.Tabs(id='main-tabs', value='market-data', children=[
|
||
|
|
dcc.Tab(label='📊 Market Data', value='market-data'),
|
||
|
|
dcc.Tab(label='🤖 Bot Management', value='bot-management'),
|
||
|
|
dcc.Tab(label='📈 Performance', value='performance'),
|
||
|
|
dcc.Tab(label='⚙️ System Health', value='system-health'),
|
||
|
|
], style={'margin-bottom': '20px'}),
|
||
|
|
|
||
|
|
# Tab content container
|
||
|
|
html.Div(id='tab-content'),
|
||
|
|
|
||
|
|
# Hidden button for callback compatibility (real button is in market data layout)
|
||
|
|
html.Button(id='add-indicator-btn', style={'display': 'none'}),
|
||
|
|
|
||
|
|
# Add Indicator Modal
|
||
|
|
create_indicator_modal(),
|
||
|
|
|
||
|
|
# Auto-refresh interval
|
||
|
|
dcc.Interval(
|
||
|
|
id='interval-component',
|
||
|
|
interval=30*1000, # Update every 30 seconds
|
||
|
|
n_intervals=0
|
||
|
|
)
|
||
|
|
])
|
||
|
|
|
||
|
|
return app
|
||
|
|
|
||
|
|
|
||
|
|
def register_callbacks(app):
|
||
|
|
"""Register all dashboard callbacks."""
|
||
|
|
from dashboard.callbacks import (
|
||
|
|
register_navigation_callbacks,
|
||
|
|
register_chart_callbacks,
|
||
|
|
register_indicator_callbacks,
|
||
|
|
register_system_health_callbacks
|
||
|
|
)
|
||
|
|
|
||
|
|
# Register all callback modules
|
||
|
|
register_navigation_callbacks(app)
|
||
|
|
register_chart_callbacks(app)
|
||
|
|
register_indicator_callbacks(app)
|
||
|
|
register_system_health_callbacks(app)
|
||
|
|
|
||
|
|
logger.info("All dashboard callbacks registered successfully")
|