修复币本位期权杠杆显示:按1/卖一而非指数/卖一

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 12:18:15 +08:00
parent 72c84bb993
commit 1314349fe5
3 changed files with 28 additions and 3 deletions
+14 -1
View File
@@ -512,12 +512,25 @@ def equivalent_contract_leverage(
index_px: float | None,
eth_amount: float | None,
total_premium: float | None,
margin_mode: str | None = None,
) -> float | None:
"""名义价值 / 权利金,近似相当于永续合约杠杆倍数(测算用)."""
"""名义价值 / 权利金,近似相当于永续合约杠杆倍数(测算用).
USDC: 权利金为美元 → index×eth/premium.
币本位: 权利金为币 → eth/premium(=1/ask 当 premium=ask×eth).
"""
if index_px is None or eth_amount is None or total_premium is None:
return None
if eth_amount <= 0 or total_premium <= 0:
return None
try:
from lib.options.options_margin_mode_lib import normalize_options_margin_mode
mode = normalize_options_margin_mode(margin_mode)
except Exception:
mode = (str(margin_mode or "usdc").strip().lower() or "usdc")
if mode == "coin":
return round(float(eth_amount) / float(total_premium), 1)
return round(float(index_px) * float(eth_amount) / float(total_premium), 1)
+1 -1
View File
@@ -64,7 +64,7 @@
<th>类型</th>
<th>合约</th>
<th>卖一/张</th>
<th title="指数÷卖一(每1币)">杠杆</th>
<th title="USDC:指数÷卖一;币本位:1÷卖一(卖一为币报价)">杠杆</th>
<th>买一/张</th>
<th>到期平衡</th>
<th>距平衡</th>