diff --git a/DEVLOG.md b/DEVLOG.md index f525464..455da6d 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -2909,3 +2909,7 @@ PMS最终代码56db0fd已推送,155 web/WS/beat为execution-2b1c447,worker 用户确认移除“观测”类别。页面统一普通、提示、警告、重要及全来源计数;无定义等级显示提示,分钟生命周期留详情,过期置灰保持。开发机80批和1440/390/320真实响应复现通过,422条计数一致。等待候选断网回归后仅155页面服务定向发布,详见[接续](docs/信号流四级统一发布_2026-11-06.md)。 12:42:09在155仅重建pms-web为pms:signal-levels-242193d,候选80批断网通过。其余18容器及私有配置保持,页面哈希与提交一致;实时1379条四级合计一致。确认与落库1665247一致,缺口、待入账和孤儿0,对账通过。文档与截图见上述接续,无自然分钟事件不冒充判收。 + +## 2026-11-09 账户累计盈亏与消息布局 + +总览增加双策略账户累计盈亏,标明实际初始化起点与未回报费用待补,估值缺失不伪装为零。消息分类统一再次点击收起,栏头和展开内容整体吸顶,侧栏高度随实际布局调整,修复滚动到底部及自动刷新时内容挤入顶部。开发机账务专项与页面三道护栏通过,1440、390、320隔离真实响应复现通过,所有写请求拒绝。仅安排155的pms-web定向发布,详见[修复接续](docs/账户盈亏与消息布局修复_2026-11-09.md)。 diff --git a/app/services/portfolio.py b/app/services/portfolio.py index 2858658..98582e0 100644 --- a/app/services/portfolio.py +++ b/app/services/portfolio.py @@ -12,6 +12,7 @@ from __future__ import annotations import json import logging +import math from app.core import cushion as cu from app.core import strategy_book as books @@ -258,6 +259,35 @@ def caps_ctx(view: dict, *, ts_code=None, is_new_name=False, sector=None) -> dic } +def account_performance() -> dict: + """只读账户累计盈亏,使用双策略现金账本的初始化基线。""" + from config.settings import settings + empty = {"ready": False, "profit": None, "started_at": None, + "reason": "账户收益基线尚未建立"} + if not settings.INFRA_STRATEGY_BOOK_SCHEMA: + return empty + try: + from app.services import rotation_accounting + view = rotation_accounting.view() + empty["started_at"] = view.get("started_at") + if not view.get("ready"): + empty["reason"] = view.get("reason") or "账户估值待补齐" + return empty + difference = view.get("cash_difference") + if difference is not None and abs(difference) > .02: + empty["reason"] = "账户现金与策略账本待核对" + return empty + profit = (view.get("metrics") or {}).get("account", {}).get("profit") + if profit is None or not math.isfinite(profit): + return empty + return {"ready": True, "profit": round(profit, 2), + "started_at": view.get("started_at"), "reason": None} + except Exception: + logger.exception("账户累计盈亏读取失败") + empty["reason"] = "账户累计盈亏暂不可用" + return empty + + def overview() -> dict: """页面顶部仪表 (总览)。任何一环取不到都不该让页面开不了 —— 逐项 try。""" try: @@ -275,6 +305,7 @@ def overview() -> dict: # 会让人以为钱多得是 (07-30: cash_est 199 万 vs 真实可用 97 万) "cash_avail": t["cash_avail"], "cash_source": t["cash_source"], "total_asset": t["total_asset"], "cash_why": t["cash_why"], + "account_performance": account_performance(), "account_market_value": t["account_market_value"], "frozen_cash": t["frozen_cash"], "float_pnl": t["float_pnl"], "float_pnl_pct": t["float_pnl_pct"], "solid_names": t["solid_names"], diff --git a/app/web/static/index.html b/app/web/static/index.html index 3d12de3..1595410 100644 --- a/app/web/static/index.html +++ b/app/web/static/index.html @@ -29,7 +29,7 @@ body{margin:0;background:var(--plane);color:var(--ink); .clr-up{color:var(--up);} .clr-down{color:var(--down);} /* 顶栏 */ /* 2026-09-18 改单行: 不折行; 状态是标签 (.hst, 与综合分析列的 .dim 同款), 动作收进右侧菜单 */ -.hd{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:10px;flex-wrap:nowrap;min-height:46px;box-sizing:border-box; +.hd{position:sticky;top:0;z-index:50;display:flex;align-items:center;gap:10px;flex-wrap:nowrap;min-height:46px;box-sizing:border-box; margin:0 -16px 6px;padding:8px 16px;background:rgba(244,245,242,.94);backdrop-filter:blur(8px);border-bottom:1px solid var(--hair);} .hd h1{font-size:15px;margin:0;font-weight:680;letter-spacing:.2px;white-space:nowrap;flex:none;} .hd .ver{color:var(--muted);font-size:12px;font-weight:400;margin-left:6px;} @@ -262,7 +262,8 @@ pre.json{background:var(--surface-2);border:1px solid var(--hair);border-radius: .ops-grid .set-fields{font-size:12.5px;} /* ── 融合消息栏: 上游告警 + 系统下单 + 待确认提议 + 策略与风控, 混成一条时间线 ── */ -.msgbar{position:sticky;top:46px;z-index:40;display:flex;align-items:center;gap:9px; +.messages{position:sticky;top:var(--pms-header-height,46px);z-index:40;padding:1px 0 4px;background:var(--plane);overflow-anchor:none;} +.msgbar{position:relative;display:flex;align-items:center;gap:9px; background:var(--surface);border:1px solid var(--hair);border-left:3px solid var(--accent); border-radius:12px;padding:7px 12px;margin:10px 0 4px;box-shadow:var(--shadow);font-size:13px;} .msgbar.lv-warn{border-left-color:var(--warn);} @@ -271,7 +272,7 @@ pre.json{background:var(--surface-2);border:1px solid var(--hair);border-radius: .mb-label{font-weight:660;color:var(--ink-2);white-space:nowrap;display:flex;align-items:center;gap:6px;} .mb-label .bell{width:7px;height:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 0 3px var(--accent-weak);} .mb-tabs{display:flex;gap:5px;} -.mb-tab{font-size:11.5px;font-weight:560;padding:2px 9px;border-radius:999px;cursor:pointer; +.mb-tab{font-family:inherit;font-size:11.5px;font-weight:560;padding:2px 9px;border-radius:999px;cursor:pointer; border:1px solid transparent;background:var(--surface-2);color:var(--ink-2);user-select:none;white-space:nowrap;} .mb-tab .n{opacity:.62;margin-left:3px;} .mb-tab.on{background:var(--accent-weak);color:var(--accent);border-color:#cfe1f8;} @@ -281,10 +282,10 @@ pre.json{background:var(--surface-2);border:1px solid var(--hair);border-radius: background:none;border:0;padding:3px 2px;white-space:nowrap;} .mb-sep{width:1px;height:15px;background:var(--hair);flex:none;} @media(max-width:1080px){ .msgbar .mb-tabs{display:none;} } -.mb-panel{position:relative;background:var(--surface);border:1px solid var(--hair);border-radius:12px; +.mb-panel{position:relative;overscroll-behavior:contain;overflow-anchor:none;background:var(--surface);border:1px solid var(--hair);border-radius:12px; box-shadow:0 12px 38px rgba(17,17,16,.14),0 2px 8px rgba(17,17,16,.06); - padding:4px 0;margin:0 0 10px;max-height:392px;overflow:auto;z-index:39;} -.mb-panel .mb-tabs{padding:7px 14px 8px;border-bottom:1px solid var(--hair);} + padding:4px 0;margin:0 0 10px;max-height:var(--pms-message-max-height,392px);overflow:auto;} +.mb-panel .mb-tabs{flex-wrap:wrap;padding:7px 14px 8px;border-bottom:1px solid var(--hair);} .mb-row{display:flex;align-items:flex-start;gap:9px;padding:6px 14px;font-size:13px;} .mb-row:hover{background:var(--surface-2);} .mb-kind{width:52px;flex:none;font-size:11px;font-weight:600;padding:1px 0;border-radius:5px;text-align:center;} @@ -301,18 +302,18 @@ pre.json{background:var(--surface-2);border:1px solid var(--hair);border-radius: /* ── 三栏骨架 ── */ .shell{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:13px;align-items:start;} -.side{position:sticky;top:96px;align-self:start;transition:width .16s ease;} +.side{position:sticky;top:var(--pms-workbench-top,96px);align-self:start;transition:width .16s ease;} .side-l,.side-r{width:var(--strip-w);} body.dock-l:not(.l-fold) .side-l{width:var(--rail-w);} body.dock-r:not(.r-fold) .side-r{width:var(--rail-w-r);} .rail{background:var(--surface);border:1px solid var(--hair);border-radius:14px;box-shadow:var(--shadow); - display:none;flex-direction:column;max-height:calc(100vh - 116px);overflow:hidden;} + display:none;flex-direction:column;max-height:calc(100vh - var(--pms-workbench-top,96px) - 64px);overflow:hidden;} body.dock-l:not(.l-fold) #railL{display:flex;} body.dock-r:not(.r-fold) #railR{display:flex;} /* 浮层几何刻意只用老写法 (2026-09-01): min()/inset 这类新函数在旧 Safari 上整条声明 被丢, 浮层就成了没背景没遮罩的"透明面板" (iPad 实锅)。宽度用 width+max-width 等价 表达; 背景先给一条固定色兜底再让变量覆盖 */ -.rail.open{display:flex;position:fixed;top:96px;bottom:18px;width:560px;max-width:88vw;max-height:none; +.rail.open{display:flex;position:fixed;top:var(--pms-overlay-top,96px);bottom:18px;width:560px;max-width:88vw;max-height:none; background:#ffffff;background:var(--surface); z-index:2010;box-shadow:0 12px 38px rgba(17,17,16,.2),0 2px 8px rgba(17,17,16,.08);} #railL.open{left:16px;} #railR.open{right:16px;} @@ -618,7 +619,7 @@ body.dock-r:not(.r-fold) .side-r .strip{display:none;} -