feat(hub): align trend pullback display with instance in fullscreen

Position cards show trend plan source, risk%, program TP price and RR; trend section uses plan grid; hub API enriches floating PnL and planned_rr.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 10:09:04 +08:00
parent 02bc3c14bc
commit 98c904c2d1
6 changed files with 263 additions and 52 deletions
+17 -2
View File
@@ -336,8 +336,23 @@ def _trend_add_leg_fields(cfg: dict, d: dict) -> dict:
def enrich_trend_plan_for_hub(cfg: dict, raw: dict) -> dict:
"""中控 /api/hub/monitor补仓次数、加仓价(交易所精度)。"""
return _trend_add_leg_fields(cfg, dict(raw or {}))
"""中控 /api/hub/monitor与策略页运行中计划卡片同字段(浮盈亏、标记价、盈亏比等)。"""
d = enrich_trend_plan(cfg, dict(raw or {}))
d["monitor_source"] = "趋势回调计划"
m = _m(cfg)
direction = (d.get("direction") or "long").lower()
try:
avg_e = float(d["avg_entry_price"])
sl = float(d["stop_loss"])
tp = float(d["take_profit"])
rr_fn = getattr(m, "calc_rr_ratio", None)
if callable(rr_fn):
rr = rr_fn(direction, avg_e, sl, tp)
if rr is not None:
d["planned_rr"] = float(rr)
except (TypeError, ValueError, KeyError):
pass
return d
def _patch_hub_monitor_enrich(app: Flask, cfg: dict) -> None: