Show option/perp PnL and fee-deducted net in trade details.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -483,6 +483,17 @@ class Matcher:
|
||||
)
|
||||
|
||||
net = perp_pnl + opt_pnl - pf.fee - of.fee
|
||||
# 组已累计开仓手续费;实现净盈亏扣开+平全部手续费
|
||||
open_fees = float(
|
||||
(
|
||||
self.db.fetchone(
|
||||
"SELECT fees FROM groups WHERE group_id=?", (group_id,)
|
||||
)
|
||||
or {"fees": 0}
|
||||
)["fees"]
|
||||
or 0
|
||||
)
|
||||
net_after_all_fees = perp_pnl + opt_pnl - open_fees - pf.fee - of.fee
|
||||
|
||||
now = int(time.time() * 1000)
|
||||
with self.db._lock:
|
||||
@@ -535,7 +546,7 @@ class Matcher:
|
||||
self.db._conn.execute(
|
||||
"""UPDATE groups SET status=?, close_at_ms=?, close_reason=?, realized_pnl=?,
|
||||
fees=?, slip_cost=?, note=NULL WHERE group_id=?""",
|
||||
("closed", now, reason, net, fees, slip, group_id),
|
||||
("closed", now, reason, net_after_all_fees, fees, slip, group_id),
|
||||
)
|
||||
self.db._conn.execute(
|
||||
"""UPDATE positions SET
|
||||
@@ -554,7 +565,9 @@ class Matcher:
|
||||
"reason": reason,
|
||||
"perp_pnl": perp_pnl,
|
||||
"option_pnl": opt_pnl,
|
||||
"net": net,
|
||||
"net": net_after_all_fees,
|
||||
"fees_open": open_fees,
|
||||
"fees_close": pf.fee + of.fee,
|
||||
"close_sequence": ["option", "perp"],
|
||||
"cash_delta": opt_cash + perp_pnl - pf.fee,
|
||||
"option_close_bid": float(close_bid),
|
||||
|
||||
Reference in New Issue
Block a user