Files
dekun ca66c494e7 Use exchange fees, UPL, funding for LIVE PnL; USDC 1:1 to USDT.
Option open P&L stays local (option net); exit target ignores estimated close fees.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 21:49:20 +08:00

21 lines
631 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""实盘金额口径:统一折 USDT(USDC 等 1:1)。"""
from __future__ import annotations
def to_usdt(amount: float, ccy: str | None = None) -> float:
"""按约定将币种金额折成 USDTUSDC/USD/USDT 一律 1:1。"""
a = float(amount or 0.0)
if a == 0.0:
return 0.0
c = (ccy or "USDT").strip().upper()
if c in ("USDT", "USDC", "USD", ""):
return a
# 其他币种暂按面值记(极少见);后续可扩汇率
return a
def abs_fee_usdt(fee: float, ccy: str | None = None) -> float:
"""手续费记为正成本(USDT)。"""
return abs(to_usdt(fee, ccy))