Include options unrealized PnL in OKX instance header realtime PnL total.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -615,6 +615,19 @@ def fetch_option_positions(ex: ccxt.okx) -> list[dict[str, Any]]:
|
||||
return []
|
||||
|
||||
|
||||
def fetch_options_unrealized_pnl_usdc(ex: ccxt.okx) -> float | None:
|
||||
"""期权持仓未实现盈亏合计(USDC,统计口径与 USDT 1:1)。"""
|
||||
total = 0.0
|
||||
found = False
|
||||
for pos in fetch_option_positions(ex):
|
||||
upl = _safe_float(pos.get("upl"))
|
||||
if upl is None:
|
||||
continue
|
||||
found = True
|
||||
total += upl
|
||||
return round(total, 4) if found else None
|
||||
|
||||
|
||||
def estimate_usdt_to_usdc(ex: ccxt.okx, usdt_amount: float) -> dict[str, Any]:
|
||||
if usdt_amount <= 0:
|
||||
return {"ok": False, "msg": "兑换数量须大于 0"}
|
||||
|
||||
Reference in New Issue
Block a user