ca66c494e7
Option open P&L stays local (option net); exit target ignores estimated close fees. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
631 B
Python
21 lines
631 B
Python
"""实盘金额口径:统一折 USDT(USDC 等 1:1)。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
|
||
def to_usdt(amount: float, ccy: str | None = None) -> float:
|
||
"""按约定将币种金额折成 USDT;USDC/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))
|