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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user