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