Label dashboard positions from monitor sources with priority.

Match hedge/roll/trend/order/key monitors for source badges, show option target monitors in green, and refresh the dashboard with the board 5s cycle.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 14:25:36 +08:00
parent 0bda44248f
commit c4c8ad172a
11 changed files with 290 additions and 28 deletions
+18
View File
@@ -175,6 +175,7 @@ def build_hub_monitor_payload(
orders,
trends,
rolls,
hedges=None,
enrich=None,
risk_status=None,
) -> dict:
@@ -185,6 +186,7 @@ def build_hub_monitor_payload(
"orders": orders,
"trends": trends,
"rolls": rolls,
"hedges": hedges if isinstance(hedges, list) else [],
"key_prices": [],
}
if isinstance(risk_status, dict):
@@ -193,6 +195,9 @@ def build_hub_monitor_payload(
extra = enrich(keys=keys, orders=orders, trends=trends, rolls=rolls)
if isinstance(extra, dict):
payload.update(extra)
# enrich 可能不返回 hedges,保留本地组装的对冲列表.
if "hedges" not in extra:
payload["hedges"] = hedges if isinstance(hedges, list) else []
return payload
@@ -572,6 +577,17 @@ def register_hub_routes(app):
rolls.append(_row_to_dict(row))
except Exception:
pass
hedges = []
try:
from lib.hedge_plan.hedge_plan_db import attach_legs_to_plans, list_plans
hedge_rows: list = []
for st in ("opening", "active", "partial"):
hedge_rows.extend(list_plans(conn, status=st, limit=80))
hedge_rows.sort(key=lambda row: int(row.get("id") or 0), reverse=True)
hedges = attach_legs_to_plans(conn, hedge_rows)
except Exception:
hedges = []
risk_status = None
risk_fn = c.get("risk_status_fn")
if callable(risk_fn):
@@ -589,6 +605,7 @@ def register_hub_routes(app):
orders=orders,
trends=trends,
rolls=rolls,
hedges=hedges,
enrich=enrich,
risk_status=risk_status,
)
@@ -601,6 +618,7 @@ def register_hub_routes(app):
orders=orders,
trends=trends,
rolls=rolls,
hedges=hedges,
risk_status=risk_status,
)
)