Shrink instance dashboard header type and show options net PnL.

Header copy is smaller; options column uses bid-recycle net PnL like the options card.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 22:04:21 +08:00
parent 173f09300b
commit 217e752ee6
6 changed files with 23 additions and 18 deletions
+1 -1
View File
@@ -263,7 +263,7 @@
);
})
.join("");
return tableWrap(["合约", "来源", "类型", "张数", "到期时间", "目标监控", "盈亏"], rows);
return tableWrap(["合约", "来源", "类型", "张数", "到期时间", "目标监控", "盈亏"], rows);
}
function renderHedgeTable(items) {
+6 -4
View File
@@ -270,10 +270,12 @@
#embed-page-root{min-height:120px;position:relative}
.embed-tab-pane[hidden]{display:none!important}
.inst-dash-card{grid-column:1/-1}
.inst-dash-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:8px}
.inst-dash-desc{margin:0;font-size:.82rem}
.inst-dash-head-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.inst-dash-status{min-height:1.2em;margin:0 0 10px}
.inst-dash-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:6px}
.inst-dash-card > .inst-dash-head h2{font-size:.88rem;margin:0 0 2px;font-weight:600}
.inst-dash-desc{margin:0;font-size:.72rem;line-height:1.35}
.inst-dash-head-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.inst-dash-updated{font-size:.72rem}
.inst-dash-status{min-height:1.1em;margin:0 0 8px;font-size:.72rem}
.inst-dash-sections{display:flex;flex-direction:column;gap:14px}
.inst-dash-section{padding:12px;background:#141923;border:1px solid #2a3150;border-radius:10px}
.inst-dash-section-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
+4 -5
View File
@@ -136,15 +136,14 @@ def _format_options_item(p: dict[str, Any], *, conn=None) -> dict[str, Any]:
inst = str(p.get("inst_id") or p.get("instId") or "-").strip() or "-"
opt_type = str(p.get("opt_type") or p.get("optType") or "").upper()
label = "Call" if opt_type == "C" else "Put" if opt_type == "P" else (opt_type or "OPT")
upl = _safe_float(p.get("upl"))
net = None
# 看板期权列固定用净盈亏(买一回收−权利金);残档买一则空.
pnl = None
try:
from lib.options.options_positions_lib import net_pnl_from_display_row
net = net_pnl_from_display_row(p)
pnl = net_pnl_from_display_row(p)
except Exception:
net = None
pnl = net if net is not None else upl
pnl = None
pos = _safe_float(p.get("pos"))
exp_ms = p.get("exp_time_ms")
if exp_ms is None:
+2 -2
View File
@@ -6,7 +6,7 @@
<script src="/static/instance_theme.js?v=50"></script>
<link rel="stylesheet" href="/static/instance_theme_early.css?v=4">
<link rel="stylesheet" href="/static/account_risk_badge.css?v=4">
<link rel="stylesheet" href="/static/instance_page.css?v=9">
<link rel="stylesheet" href="/static/instance_page.css?v=10">
<link rel="stylesheet" href="/static/instance_theme.css?v=97">
<script src="/static/account_risk_badge.js?v=4"></script>
<meta name="theme-color" content="#0b0d14">
@@ -111,7 +111,7 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
{% include 'embed_boot_scripts.html' %}
<script src="/static/records_review_page.js?v=2"></script>
<script src="/static/options_expiry_countdown.js?v=1"></script>
<script src="/static/instance_dashboard.js?v=4"></script>
<script src="/static/instance_dashboard.js?v=5"></script>
<script>
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
</script>
+2 -2
View File
@@ -16,7 +16,7 @@
<link rel="apple-touch-icon" href="/static/icons/apple-touch-icon.png">
<link rel="manifest" href="/static/icons/manifest.webmanifest">
<title>{{ pwa_app_name }}</title>
<link rel="stylesheet" href="/static/instance_page.css?v=9">
<link rel="stylesheet" href="/static/instance_page.css?v=10">
<link rel="stylesheet" href="/static/instance_theme.css?v=97">
</head>
@@ -2011,7 +2011,7 @@ setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }})
</script>
<script src="/static/records_review_page.js?v=2"></script>
<script src="/static/options_expiry_countdown.js?v=1"></script>
<script src="/static/instance_dashboard.js?v=4"></script>
<script src="/static/instance_dashboard.js?v=5"></script>
<script>
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
{% if page == 'dashboard' %}
+8 -4
View File
@@ -1,4 +1,4 @@
"""实例数据看板用的轻量期权持仓(无盘口/余额/历史)."""
"""实例数据看板用的轻量期权持仓(无余额/历史;含 close_preview 供净盈亏)."""
from __future__ import annotations
from typing import Any
@@ -6,8 +6,8 @@ from typing import Any
def fetch_light_option_positions_for_dashboard(cfg: dict[str, Any]) -> list[dict[str, Any]]:
"""
拉期权持仓 + 本地目标/对冲标注,供看板后台聚合.
不走 build_options_hub_snapshot(避免盘口/余额/历史).
拉期权持仓 + 本地目标/对冲标注 + 买一净盈亏预览,供看板后台聚合.
不走 build_options_hub_snapshot(避免余额/历史).
"""
if not cfg.get("enabled"):
return []
@@ -29,6 +29,7 @@ def fetch_light_option_positions_for_dashboard(cfg: dict[str, Any]) -> list[dict
from lib.options.options_db import init_options_tables, sum_open_premium_paid
from lib.options.options_history_lib import enrich_position_row_display
from lib.options.options_positions_lib import attach_close_preview
meta_cache: dict[str, dict[str, Any] | None] = {}
rows: list[dict[str, Any]] = []
@@ -37,7 +38,9 @@ def fetch_light_option_positions_for_dashboard(cfg: dict[str, Any]) -> list[dict
for p in raw:
if not isinstance(p, dict):
continue
rows.append(enrich_position_row_display(cfg, ex, p, meta_cache=meta_cache))
row = enrich_position_row_display(cfg, ex, p, meta_cache=meta_cache)
attach_close_preview(cfg, ex, row)
rows.append(row)
return rows
conn = get_db()
@@ -65,6 +68,7 @@ def fetch_light_option_positions_for_dashboard(cfg: dict[str, Any]) -> list[dict
meta_cache=meta_cache,
premium_override=premium_override,
)
attach_close_preview(cfg, ex, row, premium_paid=premium_override)
mon = tgt_map.get(str(row.get("inst_id") or ""))
if mon:
row["target_index"] = mon.get("target_index")