From 3577a4d2fdd88f98176c0fb50bd39d8a5ad50db9 Mon Sep 17 00:00:00 2001 From: dekun Date: Fri, 2 Oct 2026 16:18:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E9=87=91=E5=8D=A0=E6=AF=94=E5=88=86?= =?UTF-8?q?=E6=AF=8D=E6=94=B9=E4=B8=BA=E4=BD=99=E9=A2=9D=E5=8A=A0=E6=9D=83?= =?UTF-8?q?=E5=88=A9=E9=87=91=EF=BC=8C=E9=81=BF=E5=85=8D=E5=B7=B2=E4=BB=98?= =?UTF-8?q?=E6=9D=83=E5=88=A9=E9=87=91=E8=A2=AB=E6=BC=8F=E8=AE=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/hub/hub_bridge_register.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/hub/hub_bridge_register.py b/lib/hub/hub_bridge_register.py index fa27315..267fdcd 100644 --- a/lib/hub/hub_bridge_register.py +++ b/lib/hub/hub_bridge_register.py @@ -148,13 +148,17 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str, except (TypeError, ValueError): return None - # 账户资金口径:优先 USDT 资+交;都空则回退 USDC(≈U) - equity_parts = [_f(trading_usdt), _f(funding_usdt)] - if all(x is None for x in equity_parts): - equity_parts = [_f(trading_usdc), _f(funding_usdc)] - known = [x for x in equity_parts if x is not None] - equity_usdt = round(sum(known), 4) if known else None + # 账户可用余额:优先 USDT 资+交;都空则回退 USDC(≈U) + cash_parts = [_f(trading_usdt), _f(funding_usdt)] + if all(x is None for x in cash_parts): + cash_parts = [_f(trading_usdc), _f(funding_usdc)] + cash_known = [x for x in cash_parts if x is not None] + cash_usdt = round(sum(cash_known), 4) if cash_known else None premium_usdt = round(premium_total_usdt, 4) if has_premium else (0.0 if not slim_pos else None) + # 占比分母 = 当前余额 + 已付权利金(权利金已从余额扣出,需加回才是完整账户资金) + equity_usdt = None + if cash_usdt is not None or premium_usdt is not None: + equity_usdt = round(float(cash_usdt or 0.0) + float(premium_usdt or 0.0), 4) ratio_pct = None if premium_usdt is not None and equity_usdt is not None and equity_usdt > 1e-9: ratio_pct = round(float(premium_usdt) / float(equity_usdt) * 100.0, 2) @@ -164,6 +168,7 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str, } out["premium"] = { "paid_usdt": premium_usdt, + "cash_usdt": cash_usdt, "equity_usdt": equity_usdt, "ratio_pct": ratio_pct, }