币本位顶栏资金显示USDT+ETH,单笔期权本位改为下拉选择
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -103,9 +103,38 @@ def profit_loss_ratio_from_trades(trades: list[dict[str, Any]] | None) -> float
|
||||
def options_funding_label(
|
||||
funding_usdc: float | None,
|
||||
funding_usdt: float | None = None,
|
||||
funding_eth: float | None = None,
|
||||
margin_mode: str | None = None,
|
||||
underly: str = "ETH",
|
||||
) -> str:
|
||||
"""期权侧顶栏仅展示 USDC(USDT 归永续资金/交易账户).funding_usdt 参数保留兼容,忽略."""
|
||||
_ = funding_usdt
|
||||
"""期权侧顶栏文案.
|
||||
|
||||
USDC 模式:仅 USDC.
|
||||
币本位:USDT + 标的币(ETH/BTC).
|
||||
"""
|
||||
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":
|
||||
parts: list[str] = []
|
||||
if funding_usdt is not None:
|
||||
try:
|
||||
parts.append(f"{float(funding_usdt):.2f} USDT")
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
coin = funding_eth
|
||||
ccy = (underly or "ETH").strip().upper() or "ETH"
|
||||
if coin is not None:
|
||||
try:
|
||||
n = float(coin)
|
||||
txt = f"{n:.6f}".rstrip("0").rstrip(".")
|
||||
parts.append(f"{txt or '0'} {ccy}")
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
return " / ".join(parts) if parts else "—"
|
||||
if funding_usdc is None:
|
||||
return "—"
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user