Show hedge targets in control center

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 07:29:45 +08:00
parent 8f71dbe874
commit eb5c6a658b
4 changed files with 15 additions and 3 deletions
+4
View File
@@ -40,6 +40,7 @@ def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
target_monitors = list_active_targets(conn) + list_closing_targets(conn)
tgt_map = targets_by_inst(conn)
hedge_target_map = active_options_targets_by_inst(conn)
target_monitors.extend(hedge_target_map.values())
for p in positions:
mon = tgt_map.get(str(p.get("inst_id") or ""))
if mon:
@@ -49,6 +50,9 @@ def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
hedge_target = hedge_target_map.get(str(p.get("inst_id") or ""))
if hedge_target:
p["hedge_plan_target"] = hedge_target
if not mon:
# 中控卡片共用 target_index 只读展示;实际平仓仍由对冲计划监控处理。
p["target_index"] = hedge_target.get("target_index")
finally:
conn.close()
except Exception: