Fix hub options float summary blank when bid book is invalid.

Stop treating total_received=0 as a real bid recycle, fall back to exchange upl for display totals, and keep row/summary aligned.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-07 09:47:14 +08:00
parent d41028b766
commit 4bc238b014
12 changed files with 182 additions and 48 deletions
+20 -4
View File
@@ -54,11 +54,27 @@ def options_float_pnl_usdt(options_snap: dict[str, Any] | None) -> Optional[floa
if snap.get("enabled") is False or snap.get("ok") is False:
return None
upl = snap.get("upl_total_usdc")
if upl is None:
return None
if upl is not None:
try:
return round(float(upl), 4)
except (TypeError, ValueError):
pass
# 快照偶发缺合计时,按持仓行回退汇总(与卡片展示一致)
try:
return round(float(upl), 4)
except (TypeError, ValueError):
from lib.options.options_positions_lib import display_pnl_from_option_row
total = 0.0
found = False
for p in snap.get("positions") or []:
if not isinstance(p, dict):
continue
pnl = display_pnl_from_option_row(p)
if pnl is None:
continue
found = True
total += float(pnl)
return round(total, 4) if found else None
except Exception:
return None