Crash Recovery Reconciliation Kit
Reconciliation loop template for trading bots—detect and correct state drift on startup to prevent double orders and orphan positions.
What’s inside
Individual files are accessible (best for SEO/AI), plus you can download the full ZIP.
From this article
Browse allShipped asset
What's Inside
A complete implementation of crash recovery reconciliation for trading bots in TypeScript—detect state drift on startup and fix it before resuming trading.
Files in This Package
| File | Purpose |
|---|---|
| reconciliation-loop-template.ts | Full TypeScript implementation with types, detection functions, and startup sequence |
| startup-sequence-checklist.md | Step-by-step checklist for bot startup with timing estimates and abort conditions |
The Problem This Solves
Your bot crashes. On restart:
- Did that last order go through? Unknown.
- Place it again? Maybe double your position.
- Skip it? Maybe miss the trade entirely.
Without reconciliation, you're guessing. Guessing destroys accounts.
What the Reconciliation Loop Does
- Detects orphan orders — Orders on exchange that you don't have locally
- Removes ghost orders — Orders you think exist but never reached the exchange
- Backfills stale fills — Fills that happened while you were down
- Verifies position — Final truth check against exchange
Key Features
- Type-safe — Full TypeScript types for orders, positions, state
- Error handling — Timeout protection, rate limit retry, exchange-down detection
- Periodic mode — Light-weight version for runtime drift detection
- Configurable — Adopt vs. cancel orphans, drift thresholds, timeouts
Integration
Uses ccxt-style exchange interface. Implement three methods:
fetchOpenOrders(symbol)fetchOrder(clientOrderId)fetchPosition(symbol)
Works with Binance, Bybit, OKX, and any ccxt-compatible exchange.
Related Posts
Newsletter
Get the automation reliability newsletter
Weekly runbooks, failure patterns, and practical fixes.
No spam. Unsubscribe anytime.
Need help implementing this?
I can help you apply this to your systems without the drama.
Work with meSimilar resources
More resources to help you succeed