Audit fixes: LIVE symbols/fills/expiry/pending, security harden, add 更新说明.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-26 22:28:03 +08:00
parent bc8d1fb127
commit f48ea5bbcc
18 changed files with 1389 additions and 1069 deletions
+19 -2
View File
@@ -72,15 +72,32 @@ def enrich_live_unrealized(
logger.warning("live unrealized exchange overlay failed: %s", e)
option_upl = float(base.get("option_upl") or 0.0) # 期权净盈亏(本地)
# 保守预估平仓费:按现有名义×费率×2 腿,避免「刚达标、扣费后不够」
try:
from ..config import get_settings
fr = float(get_settings().fee_rate or 0.0005)
except Exception:
fr = 0.0005
notional_est = abs(float(base.get("perp_notional") or 0.0)) + abs(
float(base.get("option_notional") or 0.0)
)
if notional_est <= 0:
# 兜底:用标记价粗算
notional_est = abs(float(base.get("spot") or 0.0)) * (
abs(float(base.get("perp_qty_eth") or 0.0))
+ abs(float(base.get("option_qty_eth") or 0.0))
)
est_close = max(0.0, notional_est * fr * 2.0)
# 资金费 signed:付出为负,直接加总
net_pnl = perp_upl + option_upl - fees_paid + funding
net_pnl = perp_upl + option_upl - fees_paid + funding - est_close
out = dict(base)
out["perp_upl"] = perp_upl
out["option_upl"] = option_upl
out["fees_paid"] = fees_paid
out["funding_usdt"] = funding
out["est_close_fees"] = 0.0 # LIVE 不估平仓费
out["est_close_fees"] = est_close
out["net_pnl"] = net_pnl
out["pnl_source"] = "live_exchange"
return out