Files
trading_bot_v4/lib/trading
mindesbunister 674743c30f fix: Bug #88 - Use real Prisma IDs for smart entry trades
Smart entry timer was creating synthetic trade IDs (trade-${Date.now()})
instead of using real database IDs from createTrade() return value.

This caused SL verification to fail with Prisma error 'No record found
for update' when attempting to:
- Save SL recovery signatures (attemptSLPlacement)
- Mark trades as emergency closed (haltTradingAndClosePosition)

Fix:
- Capture createTrade() return value as savedTrade
- Use savedTrade.id for ActiveTrade object
- Add fallback for database save failures
- Log real database ID for verification

Impact: SL verification can now update smart entry trades successfully.
Both active recovery and emergency shutdown will work correctly.

Related: Bug #87 Phase 2 (active SL recovery)
2025-12-16 15:58:54 +01:00
..