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:
dekun
2026-07-17 15:12:52 +08:00
parent d5e6132b13
commit 2269bc51ff
13 changed files with 307 additions and 20 deletions
+8 -2
View File
@@ -306,13 +306,19 @@ def calc_tp_profit_usdt(
contracts: float,
contract_size: float = 1.0,
) -> Optional[float]:
"""到达止盈价时,按累计张数与加仓后均价的盈利 U."""
"""到达止盈价时,按累计张数与加仓后均价的盈利 U(扣双边 taker 费)."""
try:
from lib.hub.hub_position_metrics import estimate_linear_swap_upnl_usdt
from lib.trade.trade_fee_lib import net_pnl_after_fee
return estimate_linear_swap_upnl_usdt(
gross = estimate_linear_swap_upnl_usdt(
direction, float(avg_entry), float(take_profit_price), float(contracts), float(contract_size)
)
if gross is None:
return None
return net_pnl_after_fee(
gross, avg_entry, take_profit_price, contracts, contract_size
)
except (TypeError, ValueError):
return None