Files
trading_bot_v3/lib
mindesbunister 3ba760df2d feat: implement comprehensive orphaned order cleanup before re-entry
- Added mandatory cleanup logic when no position detected before re-entry attempts
- Enhanced cleanup with dual-endpoint approach: cleanup-orders + cancel-all-orders fallback
- Added pre-trade cleanup before executing new trades to prevent order conflicts
- Implemented verification delays and safety checks for cleanup completion
- Added detailed logging for cleanup operations and results

Features:
 Mandatory cleanup when no position detected (re-entry scenario)
 Pre-trade cleanup before new trade execution
 Dual cleanup strategy: cleanup-orders -> cancel-all-orders if needed
 Fallback error handling with alternative cleanup methods
 Verification delays to ensure cleanup processing
 Preserves legitimate TP/SL orders when position exists

Testing verified:
- Properly preserves 2 active TP/SL orders when position exists (90 SL, 95 TP)
- Cleanup logic correctly identifies 0 orphaned orders with active position
- System maintains order integrity while enabling aggressive re-entry when needed
2025-07-28 12:53:23 +02:00
..