diff --git a/manual_trading_hub/hub_ai/context.py b/manual_trading_hub/hub_ai/context.py index bc96493..f444d85 100644 --- a/manual_trading_hub/hub_ai/context.py +++ b/manual_trading_hub/hub_ai/context.py @@ -1059,6 +1059,30 @@ def resolve_position_monitor_source(pos: dict, hub_mon: Optional[dict]) -> str: return candidates[0][1] +def resolve_position_reward_at_tp(pos: dict, hub_mon: Optional[dict]) -> Optional[float]: + """与监控区「盈利金额」一致:优先匹配下单监控 reward_at_tp_usdt,否则仓位自身字段.""" + sym = str(pos.get("symbol") or "") + side = str(pos.get("side") or "") + if isinstance(hub_mon, dict) and hub_mon.get("ok") is not False and sym: + # 与前端 findMonitorOrder 一致:先扫 orders + for o in hub_mon.get("orders") or []: + if isinstance(o, dict) and _monitor_item_matches_position(o, sym, side): + v = _safe_float(o.get("reward_at_tp_usdt")) + if v is not None: + return v + for r in hub_mon.get("rolls") or []: + if isinstance(r, dict) and _monitor_item_matches_position(r, sym, side): + v = _safe_float(r.get("reward_at_tp_usdt")) + if v is not None: + return v + for t in hub_mon.get("trends") or []: + if isinstance(t, dict) and _monitor_item_matches_position(t, sym, side): + v = _safe_float(t.get("reward_at_tp_usdt")) + if v is not None: + return v + return _safe_float(pos.get("reward_at_tp_usdt")) + + def _options_source_label(p: dict) -> str: """看板期权来源:期期/永期对冲,其余为纯期权.""" source = str(p.get("source") or "").strip() @@ -1105,6 +1129,7 @@ def format_dashboard_account_detail(ac: dict) -> dict[str, Any]: notional = _safe_float(p.get("notional_usdt")) if notional is None: notional = _safe_float(p.get("notional")) + reward_tp = resolve_position_reward_at_tp(p, hub_mon) position_lines.append( { "kind": "position", @@ -1117,6 +1142,7 @@ def format_dashboard_account_detail(ac: dict) -> dict[str, Any]: "mark_price": mark, "mark_price_fmt": p.get("mark_price_fmt"), "notional_usdt": notional, + "reward_at_tp_usdt": round(reward_tp, 4) if reward_tp is not None else None, "text": f"{sym} {side}", "pnl": round(upnl, 4), } diff --git a/manual_trading_hub/static/app.js b/manual_trading_hub/static/app.js index a2013f3..50a8f62 100644 --- a/manual_trading_hub/static/app.js +++ b/manual_trading_hub/static/app.js @@ -2528,6 +2528,17 @@ renderMonitorGrid(lastMonitorRows); }; }); + fsInner.querySelectorAll(".btn-expand-dashboard").forEach((btn) => { + btn.onclick = (ev) => { + ev.stopPropagation(); + closeExchangeFullscreen(); + if (window.hubNavigateTo) window.hubNavigateTo("/dashboard"); + else { + history.pushState({}, "", "/dashboard"); + setActiveNav(); + } + }; + }); } catch (err) { console.error("renderFullscreenExchange", err); closeExchangeFullscreen(); @@ -4000,6 +4011,7 @@