Introduction
In the fast-paced world of crypto spot markets, maintaining continuous and reliable liquidity is crucial for both token projects and exchanges. Automated market making bots, such as those built on Atlas LP, play a central role by placing resting limit orders that any participant can trade against. However, interruptions—whether due to network issues, exchange downtime, or software updates—are inevitable. Engineering a bot that can safely restart and recover its state is essential for minimizing disruption and avoiding operational risks.
This article explores the technical challenges and best practices for resilient bot restart and recovery in crypto market making, focusing on real-world engineering considerations and the safeguards implemented in Atlas LP.
Why Resilient Restart and Recovery Matter
Market making bots operate in real time, continuously syncing with exchange order books, balances, and open orders. Any interruption can leave the bot out of sync with the true state of the market or its own orders, potentially leading to:
- Duplicate or orphaned orders
- Missed fills or incorrect balance calculations
- Unintended exposure to market risk
- Loss of confidence from token projects or exchanges relying on stable liquidity
A robust restart and recovery process ensures that, after any interruption, the bot can:
- Reconnect to the exchange securely
- Accurately reconstruct its open orders, fills, and balances
- Resume its market making strategy without creating inconsistencies or operational hazards
Core Principles of Safe Bot Recovery
1. State Reconstruction from the Exchange
Upon restart, a market making bot should never rely solely on its previous in-memory state. Instead, it must fetch the latest data directly from the exchange API, including:
- Current open orders for the relevant symbol
- Recent fills and trade history
- Account balances
- Latest ticker and order book data
This approach ensures that any orders placed before the interruption are accounted for, and that the bot’s view of the market matches the exchange’s actual state.
2. Idempotent Order Management
A key engineering challenge is avoiding duplicate or conflicting orders after a restart. The bot must:
- Identify which open orders belong to its current strategy
- Cancel any excess or mispriced orders that do not fit the desired ladder
- Place only the missing levels needed to restore the intended spread and depth
Atlas LP’s approach is to compute the desired order ladder each tick, then compare it to the actual open orders retrieved from the exchange. Only orders that are missing or misaligned are adjusted, making the process idempotent and safe to repeat after any interruption.
3. Secure API Credential Handling
Security is paramount, especially when reconnecting after a restart. Atlas LP encrypts all API keys and secrets with AES-256-GCM, ensuring they are only decrypted by the worker process that communicates with the exchange. Withdrawal permissions are never requested, and credentials are never displayed after initial entry. This minimizes the risk of credential leakage during recovery.
4. Data Freshness and Consistency Checks
After a restart, the bot must validate that all retrieved data is fresh and consistent:
- Ticker and order book data must not be stale or crossed
- Symbol rules (such as minimum order size and notional) must be re-validated
- Balances and open orders must be reconciled with recent fills
Atlas LP skips ticks if data is stale or inconsistent, preventing erroneous order placement.
5. Event Logging and User Transparency
A resilient bot should provide clear feedback to users about its recovery actions. Atlas LP logs all bot events, including order placements, cancellations, fills, and errors, in the console. This transparency allows users to monitor the recovery process and intervene if necessary, such as by manually canceling orders or stopping the bot.
Practical Steps for Engineering Bot Restart and Recovery
Step 1: Fetch and Verify Exchange State
Immediately upon restart, the bot should:
- Retrieve all open orders for the relevant symbol
- Fetch recent fills and update internal fill records
- Sync account balances
- Validate ticker and order book data
Step 2: Recalculate Desired Order Ladder
Based on the current market and bot settings (spread bands, number of levels, order sizes, etc.), the bot computes the set of limit orders that should be present.
Step 3: Reconcile and Adjust Orders
- Cancel any open orders that are not part of the desired ladder or are mispriced
- Place any missing orders to restore the intended spread and depth
- Ensure all new orders meet exchange minimum quantity and notional requirements
Step 4: Resume Normal Tick Cycle
Once reconciliation is complete, the bot resumes its regular tick cycle, continuously monitoring the market and adjusting orders as needed.
Step 5: Notify Users of Recovery Status
Send alerts or log events to inform users that the bot has restarted, reconciled state, and resumed operation. Atlas LP also supports Telegram alerts for key events such as inactivity or errors.
Common Pitfalls and How to Avoid Them
| Pitfall | How to Avoid |
|---|
| Relying on cached state | Always fetch open orders, fills, and balances from the exchange on restart |
| Duplicating orders | Compare desired ladder to actual open orders before placing new orders |
| Failing to cancel excess | Proactively cancel orders not aligned with current strategy |
| Ignoring stale data | Validate data freshness before acting |
| Security lapses | Encrypt API keys and restrict permissions |
Atlas LP’s Approach to Restart and Recovery
Atlas LP is designed with resilient recovery in mind:
- API Verification: On restart, Atlas LP re-verifies API credentials, checks balances, open orders, trades, and can optionally place a test limit order to confirm trading permission.
- Order Ladder Reconciliation: Each tick, the bot recalculates the desired order ladder and synchronizes it with the actual state on the exchange, ensuring no duplicate or orphaned orders.
- Data Validation: The bot skips processing if order book or ticker data is stale or crossed, preventing erroneous actions.
- User Controls: Users can cancel individual or all open orders directly from the console, and stopping the bot halts new order placements.
- Security: All API keys are encrypted and never displayed after entry. Withdrawal permissions are never requested.
Conclusion
Resilient restart and recovery are foundational to reliable crypto market making. By prioritizing state reconstruction, idempotent order management, secure credential handling, and transparent event logging, engineering teams can ensure that bots like Atlas LP maintain continuous, safe, and compliant liquidity provision—even in the face of interruptions.
To learn more about Atlas LP’s spot liquidity bot and its engineering safeguards, visit the liquidity bot overview or explore supported exchanges.
Atlas LP does not guarantee returns, prices, volume, or listings.
Crypto trading involves risk. Atlas LP is software for placing and managing limit orders; it does not guarantee returns, prices, volume or listings. Follow the rules of each exchange and applicable law.