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
+11 -3
View File
@@ -16,7 +16,7 @@ def reward_at_tp_usdt(
*,
contract_size: float = 1.0,
) -> Optional[float]:
"""与 strategy_roll_lib.preview_roll 一致:线性合约 U 本位盈利."""
"""与 strategy_roll_lib.preview_roll 一致:线性合约 U 本位盈利(扣双边 taker 费)."""
try:
avg = float(avg_entry)
tp = float(take_profit)
@@ -28,8 +28,16 @@ def reward_at_tp_usdt(
return None
direction = (direction or "long").strip().lower()
if direction == "short":
return (avg - tp) * q * cs
return (tp - avg) * q * cs
gross = (avg - tp) * q * cs
else:
gross = (tp - avg) * q * cs
try:
from lib.trade.trade_fee_lib import net_pnl_after_fee
net = net_pnl_after_fee(gross, avg, tp, q, cs)
return net
except Exception:
return gross
def leg_fill_price(leg: dict) -> Optional[float]: