Bot restart causes duplicate orders or orphan state
After crash or restart, reconciliation is incomplete and live state diverges from exchange truth. Without startup guards and idempotent reconciliation loops, duplicates are likely.
Common symptom variants
Primary playbook
Build crash-proof trading bots with reconciliation loops that detect and correct out-of-sync state on restart—preventing double orders and orphan positions.
Recommended resource
Reconciliation loop template for trading bots—detect and correct state drift on startup to prevent double orders and orphan positions.
Related posts
WebSocket Reconnection That Actually Works: Auto-Reconnect Guide for Trading Bots
Complete WebSocket auto-reconnect guide for trading bots. Implement automatic reconnection with exponential backoff, heartbeat ping-pong, message gap detection, and state recovery. Production-tested TypeScript code included.
Idempotency keys for APIs: stop duplicate orders, emails, and writes
When retries create duplicate side effects, idempotency keys are the only safe fix. This playbook shows how to design keys, store results, and prove duplicates cannot recur.