持仓卡与中控快照增加期权杠杆倍数展示。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-05 06:47:49 +08:00
parent 7b432bc964
commit d743185f05
6 changed files with 94 additions and 1 deletions
+14
View File
@@ -99,6 +99,19 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
if premium_usdt is not None:
has_premium = True
premium_total_usdt += float(premium_usdt)
contract_leverage = p.get("contract_leverage")
if contract_leverage is None:
try:
from lib.options.options_pricing_lib import equivalent_contract_leverage
contract_leverage = equivalent_contract_leverage(
index_px=p.get("idx_px") or p.get("index_px"),
eth_amount=p.get("eth_amount"),
total_premium=premium_paid,
margin_mode=p.get("margin_mode"),
)
except Exception:
contract_leverage = None
slim_pos.append(
{
"inst_id": p.get("inst_id"),
@@ -108,6 +121,7 @@ def _enrich_hub_protocol(snap: dict[str, Any], *, app_module: Any) -> dict[str,
"premium_paid": premium_paid,
"premium_paid_usdt": round(float(premium_usdt), 4) if premium_usdt is not None else None,
"premium_ccy": p.get("premium_ccy"),
"contract_leverage": contract_leverage,
"mark": p.get("mark") or p.get("mark_px"),
"underlying": p.get("underlying"),
"source_label": p.get("source_label"),