Files
trading_bot_v4/pnl_correction.sql
mindesbunister 1dccf23fe4 fix: Correct P&L for last 2 trades to match Drift UI actual values
Trade 1: cmibdii4k0004pe07nzfmturo (Nov 23, 07:05)
- Database had: +$6.44 profit (wrong exit price $128.79)
- Drift UI shows: -$59.59 loss
- Corrected: SHORT from $128.729 → $130.167 (price UP = loss)
- Size: 40.18 SOL (~$5,173 notional)

Trade 2: cmiahpupc0000pe07g2dh58ow (Nov 22, 16:15)
- Database had: LONG with -$22.41 loss
- Drift UI shows: +$31.45 profit
- Corrected: Changed to SHORT from $128.729 → $128.209 (price DOWN = profit)
- Size: 60.25 SOL (~$7,756 notional)

Root Cause: External closure P&L calculation using stale monitoring price
instead of Drift's settled P&L. Common Pitfall #57 fix exists but these
trades occurred before Nov 16 container restart with the fix.

Verification: SQL calculations now match Drift UI screenshot exactly.

Manual correction applied via SQL UPDATE statements.
2025-11-23 11:12:08 +01:00

26 lines
810 B
SQL

-- Manual P&L correction for trades with wrong entry/exit data
-- Nov 23, 2025 - Verified against Drift UI screenshot
-- Trade 1: cmibdii4k0004pe07nzfmturo (9 minutes ago)
-- Was: +$6.44 profit (wrong exit price)
-- Correct: -$59.59 loss (SHORT, price went UP from $128.729 to $130.167)
UPDATE "Trade"
SET
"entryPrice" = 128.729,
"exitPrice" = 130.167,
"positionSizeUSD" = 5173.00,
"realizedPnL" = -59.59
WHERE id = 'cmibdii4k0004pe07nzfmturo';
-- Trade 2: cmiahpupc0000pe07g2dh58ow (2 hours ago)
-- Was: LONG with -$22.41 loss
-- Correct: SHORT with +$31.45 profit (price went DOWN from $128.729 to $128.209)
UPDATE "Trade"
SET
direction = 'short',
"entryPrice" = 128.729,
"exitPrice" = 128.209,
"positionSizeUSD" = 7756.00,
"realizedPnL" = 31.45
WHERE id = 'cmiahpupc0000pe07g2dh58ow';