- Deleted `app_new.py`, which was previously the main entry point for the dashboard application, to streamline the codebase. - Consolidated the application initialization and callback registration logic into `main.py`, enhancing modularity and maintainability. - Updated the logging and error handling practices in `main.py` to ensure consistent application behavior and improved debugging capabilities. These changes simplify the application structure, aligning with project standards for modularity and maintainability.
123 lines
4.4 KiB
Python
123 lines
4.4 KiB
Python
"""
|
||
Chart control components for the market data layout.
|
||
"""
|
||
|
||
from dash import html, dcc
|
||
import dash_bootstrap_components as dbc
|
||
from utils.logger import get_logger
|
||
from utils.time_range_utils import load_time_range_options
|
||
|
||
logger = get_logger("default_logger")
|
||
|
||
def create_chart_config_panel(strategy_options, overlay_options, subplot_options):
|
||
"""Create the chart configuration panel with add/edit UI."""
|
||
return dbc.Card([
|
||
dbc.CardHeader(html.H5("🎯 Chart Configuration")),
|
||
dbc.CardBody([
|
||
dbc.Button("➕ Add New Indicator", id="add-indicator-btn-visible", color="primary", className="mb-3"),
|
||
|
||
html.Div([
|
||
html.Label("Strategy Template:", className="form-label"),
|
||
dcc.Dropdown(
|
||
id='strategy-dropdown',
|
||
options=strategy_options,
|
||
value=None,
|
||
placeholder="Select a strategy template (optional)",
|
||
)
|
||
], className="mb-3"),
|
||
|
||
dbc.Row([
|
||
dbc.Col([
|
||
html.Label("Overlay Indicators:", className="form-label"),
|
||
dcc.Checklist(
|
||
id='overlay-indicators-checklist',
|
||
options=overlay_options,
|
||
value=[],
|
||
style={'display': 'none'}
|
||
),
|
||
html.Div(id='overlay-indicators-list')
|
||
], width=6),
|
||
|
||
dbc.Col([
|
||
html.Label("Subplot Indicators:", className="form-label"),
|
||
dcc.Checklist(
|
||
id='subplot-indicators-checklist',
|
||
options=subplot_options,
|
||
value=[],
|
||
style={'display': 'none'}
|
||
),
|
||
html.Div(id='subplot-indicators-list')
|
||
], width=6)
|
||
])
|
||
])
|
||
], className="mb-4")
|
||
|
||
|
||
def create_auto_update_control():
|
||
"""Create the auto-update control section."""
|
||
return html.Div([
|
||
dbc.Checkbox(
|
||
id='auto-update-checkbox',
|
||
label='Auto-update charts',
|
||
value=True,
|
||
),
|
||
html.Div(id='update-status', style={'font-size': '12px', 'color': '#7f8c8d'})
|
||
], className="mb-3")
|
||
|
||
|
||
def create_time_range_controls():
|
||
"""Create the time range control panel."""
|
||
return dbc.Card([
|
||
dbc.CardHeader(html.H5("⏰ Time Range Controls")),
|
||
dbc.CardBody([
|
||
html.Div([
|
||
html.Label("Quick Select:", className="form-label"),
|
||
dcc.Dropdown(
|
||
id='time-range-quick-select',
|
||
options=load_time_range_options(),
|
||
value='7d',
|
||
placeholder="Select time range",
|
||
)
|
||
], className="mb-3"),
|
||
|
||
html.Div([
|
||
html.Label("Custom Date Range:", className="form-label"),
|
||
dbc.InputGroup([
|
||
dcc.DatePickerRange(
|
||
id='custom-date-range',
|
||
display_format='YYYY-MM-DD',
|
||
),
|
||
dbc.Button("Clear", id="clear-date-range-btn", color="secondary", outline=True, size="sm")
|
||
])
|
||
], className="mb-3"),
|
||
|
||
html.Div([
|
||
html.Label("Analysis Mode:", className="form-label"),
|
||
dbc.RadioItems(
|
||
id='analysis-mode-toggle',
|
||
options=[
|
||
{'label': '🔴 Real-time Updates', 'value': 'realtime'},
|
||
{'label': '🔒 Analysis Mode (Locked)', 'value': 'locked'}
|
||
],
|
||
value='realtime',
|
||
inline=True,
|
||
)
|
||
]),
|
||
|
||
html.Div(id='time-range-status', className="text-muted fst-italic mt-2")
|
||
])
|
||
], className="mb-4")
|
||
|
||
|
||
def create_export_controls():
|
||
"""Create the data export control panel."""
|
||
return dbc.Card([
|
||
dbc.CardHeader(html.H5("💾 Data Export")),
|
||
dbc.CardBody([
|
||
dbc.ButtonGroup([
|
||
dbc.Button("Export to CSV", id="export-csv-btn", color="primary"),
|
||
dbc.Button("Export to JSON", id="export-json-btn", color="secondary"),
|
||
]),
|
||
dcc.Download(id="download-chart-data")
|
||
])
|
||
], className="mb-4") |