Files
trading_bot_v4/lib
mindesbunister 1426a9ec2f CRITICAL FIX: P&L calculation using wrong position size for phantom trades
- Position Manager was calculating P&L using tracked size instead of actual on-chain size
- Example: Tracked 100, actual 0.04 SOL () = -99.63% false loss instead of -0.32%
- Fixed external closure detection to use position.size * currentPrice as lastKnownSize
- Manually corrected phantom trade P&L from -092.25 to /bin/bash
- Total P&L corrected: -013.92 → +8.33 (accurate)
- Prevents all future phantom/mismatch trades from wildly incorrect P&L

Modified:
- lib/trading/position-manager.ts lines 421-445 (external closure P&L calculation)
2025-11-03 16:57:53 +01:00
..