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
+5 -5
View File
@@ -66,17 +66,17 @@ def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
conn.close()
except Exception:
target_monitors = []
from lib.options.options_positions_lib import net_pnl_from_display_row
from lib.options.options_positions_lib import display_pnl_from_option_row
upl_total = 0.0
has_upl = False
for p in positions:
# 与持仓卡「净盈亏」一致(买一回收−权利金);不用交易所标记价 upl
net = net_pnl_from_display_row(p)
if net is None:
# 与持仓卡展示一致:优先买一净盈亏,残档回退交易所 upl
pnl = display_pnl_from_option_row(p)
if pnl is None:
continue
has_upl = True
upl_total += float(net)
upl_total += float(pnl)
bal = cfg["fetch_options_balances"](ex)
return {
"ok": True,