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
+10 -2
View File
@@ -143,8 +143,16 @@ def reward_at_tp_usdt(
cs = float(contract_size or 1.0)
direction = (direction or "long").strip().lower()
if direction == "short":
return (float(avg) - float(take_profit)) * float(qty) * cs
return (float(take_profit) - float(avg)) * float(qty) * cs
gross = (float(avg) - float(take_profit)) * float(qty) * cs
else:
gross = (float(take_profit) - float(avg)) * float(qty) * cs
try:
from lib.trade.trade_fee_lib import net_pnl_after_fee
net = net_pnl_after_fee(gross, avg, take_profit, qty, cs)
return float(net) if net is not None else gross
except Exception:
return gross
def roll_fib_trigger_crossed(