fixed cob
This commit is contained in:
@ -272,13 +272,14 @@ class DashboardComponentManager:
|
||||
logger.error(f"Error formatting system status: {e}")
|
||||
return [html.P(f"Error: {str(e)}", className="text-danger small")]
|
||||
|
||||
def format_cob_data(self, cob_snapshot, symbol, cumulative_imbalance_stats=None):
|
||||
def format_cob_data(self, cob_snapshot, symbol, cumulative_imbalance_stats=None, cob_mode="Unknown"):
|
||||
"""Format COB data into a split view with summary, imbalance stats, and a compact ladder."""
|
||||
try:
|
||||
if not cob_snapshot:
|
||||
return html.Div([
|
||||
html.H6(f"{symbol} COB", className="mb-2"),
|
||||
html.P("No COB data available", className="text-muted small")
|
||||
html.P("No COB data available", className="text-muted small"),
|
||||
html.P(f"Mode: {cob_mode}", className="text-muted small")
|
||||
])
|
||||
|
||||
# Handle both old format (with stats attribute) and new format (direct attributes)
|
||||
@ -316,7 +317,7 @@ class DashboardComponentManager:
|
||||
}
|
||||
|
||||
# --- Left Panel: Overview and Stats ---
|
||||
overview_panel = self._create_cob_overview_panel(symbol, stats, cumulative_imbalance_stats)
|
||||
overview_panel = self._create_cob_overview_panel(symbol, stats, cumulative_imbalance_stats, cob_mode)
|
||||
|
||||
# --- Right Panel: Compact Ladder ---
|
||||
ladder_panel = self._create_cob_ladder_panel(bids, asks, mid_price, symbol)
|
||||
@ -330,7 +331,7 @@ class DashboardComponentManager:
|
||||
logger.error(f"Error formatting split COB data: {e}")
|
||||
return html.P(f"Error: {str(e)}", className="text-danger small")
|
||||
|
||||
def _create_cob_overview_panel(self, symbol, stats, cumulative_imbalance_stats):
|
||||
def _create_cob_overview_panel(self, symbol, stats, cumulative_imbalance_stats, cob_mode="Unknown"):
|
||||
"""Creates the left panel with summary and imbalance stats."""
|
||||
mid_price = stats.get('mid_price', 0)
|
||||
spread_bps = stats.get('spread_bps', 0)
|
||||
@ -342,6 +343,10 @@ class DashboardComponentManager:
|
||||
imbalance_text = f"Bid Heavy ({imbalance:.3f})" if imbalance > 0 else f"Ask Heavy ({imbalance:.3f})"
|
||||
imbalance_color = "text-success" if imbalance > 0 else "text-danger"
|
||||
|
||||
# COB mode indicator
|
||||
mode_color = "text-success" if cob_mode == "WS" else "text-warning" if cob_mode == "REST" else "text-muted"
|
||||
mode_icon = "fas fa-wifi" if cob_mode == "WS" else "fas fa-globe" if cob_mode == "REST" else "fas fa-question"
|
||||
|
||||
imbalance_stats_display = []
|
||||
if cumulative_imbalance_stats:
|
||||
imbalance_stats_display.append(html.H6("Cumulative Imbalance", className="mt-3 mb-2 small text-muted text-uppercase"))
|
||||
@ -350,6 +355,12 @@ class DashboardComponentManager:
|
||||
|
||||
return html.Div([
|
||||
html.H6(f"{symbol} - COB Overview", className="mb-2"),
|
||||
html.Div([
|
||||
html.Span([
|
||||
html.I(className=f"{mode_icon} me-1 {mode_color}"),
|
||||
html.Span(f"Mode: {cob_mode}", className=f"small {mode_color}")
|
||||
], className="mb-2")
|
||||
]),
|
||||
html.Div([
|
||||
self._create_stat_card("Mid Price", f"${mid_price:,.2f}", "fas fa-dollar-sign"),
|
||||
self._create_stat_card("Spread", f"{spread_bps:.1f} bps", "fas fa-arrows-alt-h")
|
||||
|
Reference in New Issue
Block a user