84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
"""
|
|
Dash application setup for interactive orderflow visualization.
|
|
|
|
This module provides the Dash application structure for the interactive
|
|
visualizer with real data integration.
|
|
"""
|
|
|
|
import dash
|
|
from dash import html, dcc
|
|
import dash_bootstrap_components as dbc
|
|
from typing import Optional, List, Tuple, Dict, Any
|
|
from models import Metric
|
|
|
|
|
|
def create_dash_app(
|
|
ohlc_data: Optional[List[Tuple[int, float, float, float, float, float]]] = None,
|
|
metrics_data: Optional[List[Metric]] = None,
|
|
debug: bool = False,
|
|
port: int = 8050
|
|
) -> dash.Dash:
|
|
"""
|
|
Create and configure a Dash application with real data.
|
|
|
|
Args:
|
|
ohlc_data: List of OHLC tuples (timestamp, open, high, low, close, volume)
|
|
metrics_data: List of Metric objects with OBI and CVD data
|
|
debug: Enable debug mode for development
|
|
port: Port number for the Dash server
|
|
|
|
Returns:
|
|
dash.Dash: Configured Dash application instance
|
|
"""
|
|
app = dash.Dash(
|
|
__name__,
|
|
external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.themes.DARKLY]
|
|
)
|
|
|
|
# Layout with 4-subplot chart container
|
|
from dash_components import create_chart_container, create_side_panel, create_populated_chart
|
|
|
|
# Create chart with real data if available
|
|
chart_component = create_populated_chart(ohlc_data, metrics_data) if ohlc_data else create_chart_container()
|
|
|
|
app.layout = dbc.Container([
|
|
dbc.Row([
|
|
dbc.Col([
|
|
html.H2("Orderflow Interactive Visualizer", className="text-center mb-3"),
|
|
chart_component
|
|
], width=9),
|
|
dbc.Col([
|
|
create_side_panel()
|
|
], width=3)
|
|
])
|
|
], fluid=True)
|
|
|
|
return app
|
|
|
|
|
|
def create_dash_app_with_data(
|
|
ohlc_data: List[Tuple[int, float, float, float, float, float]],
|
|
metrics_data: List[Metric],
|
|
debug: bool = False,
|
|
port: int = 8050
|
|
) -> dash.Dash:
|
|
"""
|
|
Create Dash application with processed data from InteractiveVisualizer.
|
|
|
|
Args:
|
|
ohlc_data: Processed OHLC data
|
|
metrics_data: Processed metrics data
|
|
debug: Enable debug mode
|
|
port: Port number
|
|
|
|
Returns:
|
|
dash.Dash: Configured Dash application with real data
|
|
"""
|
|
return create_dash_app(ohlc_data, metrics_data, debug, port)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Development server for testing
|
|
app = create_dash_app(debug=True)
|
|
app.run(debug=True, port=8050)
|