Deduct round-trip taker fees from estimated perp PnL.
Unify hub/instance TP profit, calc_pnl, and push/accounting to net of 0.05% per side; leave exchange floating PnL unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2261,6 +2261,7 @@ def format_hold_minutes(minutes):
|
||||
|
||||
|
||||
def calc_pnl(direction, trigger_price, exit_price, margin_capital, leverage):
|
||||
"""估算净盈亏(USDT):价差毛利 − 双边 taker 费(默认各 0.05%)."""
|
||||
try:
|
||||
trigger = float(trigger_price)
|
||||
exit_p = float(exit_price)
|
||||
@@ -2272,7 +2273,15 @@ def calc_pnl(direction, trigger_price, exit_price, margin_capital, leverage):
|
||||
pnl_ratio = (trigger - exit_p) / trigger
|
||||
else:
|
||||
pnl_ratio = (exit_p - trigger) / trigger
|
||||
return round(margin * lev * pnl_ratio, 4)
|
||||
notional = margin * lev
|
||||
gross = notional * pnl_ratio
|
||||
try:
|
||||
from lib.trade.trade_fee_lib import net_pnl_after_fee
|
||||
|
||||
net = net_pnl_after_fee(gross, trigger, exit_p, open_notional=notional)
|
||||
return float(net) if net is not None else round(gross, 4)
|
||||
except Exception:
|
||||
return round(gross, 4)
|
||||
except Exception:
|
||||
return 0.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user