cob ma data for models

This commit is contained in:
Dobromir Popov
2025-09-09 02:07:04 +03:00
parent 317c703ea0
commit 729e0bccb1
3 changed files with 132 additions and 11 deletions

View File

@@ -272,7 +272,7 @@ 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, cob_mode="Unknown"):
def format_cob_data(self, cob_snapshot, symbol, cumulative_imbalance_stats=None, cob_mode="Unknown", imbalance_ma_data=None):
"""Format COB data into a split view with summary, imbalance stats, and a compact ladder."""
try:
if not cob_snapshot:
@@ -317,7 +317,7 @@ class DashboardComponentManager:
}
# --- Left Panel: Overview and Stats ---
overview_panel = self._create_cob_overview_panel(symbol, stats, cumulative_imbalance_stats, cob_mode)
overview_panel = self._create_cob_overview_panel(symbol, stats, cumulative_imbalance_stats, cob_mode, imbalance_ma_data)
# --- Right Panel: Compact Ladder ---
ladder_panel = self._create_cob_ladder_panel(bids, asks, mid_price, symbol)
@@ -331,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, cob_mode="Unknown"):
def _create_cob_overview_panel(self, symbol, stats, cumulative_imbalance_stats, cob_mode="Unknown", imbalance_ma_data=None):
"""Creates the left panel with summary and imbalance stats."""
mid_price = stats.get('mid_price', 0)
spread_bps = stats.get('spread_bps', 0)
@@ -373,6 +373,20 @@ class DashboardComponentManager:
html.Div(imbalance_stats_display),
# COB Imbalance Moving Averages
ma_display = []
if imbalance_ma_data:
ma_display.append(html.H6("Imbalance MAs", className="mt-3 mb-2 small text-muted text-uppercase"))
for timeframe, ma_value in imbalance_ma_data.items():
ma_color = "text-success" if ma_value > 0 else "text-danger"
ma_text = f"MA {timeframe}: {ma_value:.3f}"
ma_display.append(html.Div([
html.Strong(f"{timeframe}: ", className="small"),
html.Span(ma_text, className=f"small {ma_color}")
], className="mb-1"))
html.Div(ma_display),
html.Hr(className="my-2"),
html.Table([