Atlas LP
  1. Home
  2. Blog
  3. Engineering Reliable Order Cancellation for Crypto Market Making Bots

Engineering

Engineering Reliable Order Cancellation for Crypto Market Making Bots

Explore the technical challenges and solutions for ensuring timely, accurate order cancellation in automated spot market making bots, with a focus on robust engineering practices.

Published

Introduction

Order cancellation is a fundamental operation for any crypto market making bot. In spot markets, maintaining an accurate and up-to-date set of resting limit orders is essential for providing liquidity, managing inventory, and controlling risk. However, reliably canceling orders—especially in volatile, fast-moving markets—presents unique engineering challenges. This post explores the technical considerations and best practices for building robust order cancellation workflows in automated spot market making, with reference to Atlas LP’s approach.

Why Reliable Order Cancellation Matters

Market makers must continuously adapt their order books to reflect changing market conditions, inventory targets, and risk parameters. When a bot determines that an order is no longer needed—because it is mispriced, exceeds the desired number of levels, or violates updated strategy parameters—it must cancel that order promptly and accurately.

Failures in order cancellation can result in:

  • Unintended exposures: Old or mispriced orders may be filled, leading to unwanted inventory or losses.
  • Regulatory or exchange compliance issues: Some exchanges penalize excessive open orders or stale quotes.
  • Distorted market signals: Resting orders that are not updated can mislead other participants and reduce overall market quality.

Technical Challenges in Order Cancellation

1. Exchange API Reliability and Latency

Order cancellation relies on the exchange’s API. Issues such as network latency, API rate limits, and intermittent downtime can delay or prevent successful cancellations. Bots must be able to detect and handle these scenarios gracefully.

2. Accurate Order Tracking

To cancel the correct orders, the bot must maintain an up-to-date record of all open orders, including their unique IDs as assigned by the exchange. Discrepancies between the bot’s internal state and the exchange’s actual order book can lead to failed or duplicate cancellation attempts.

3. Handling Partial Fills and Race Conditions

Orders may be partially filled or fully executed before a cancellation request is processed. Bots must reconcile fill events with cancellation responses and ensure that they do not attempt to cancel already-closed orders.

4. API Error Handling

Exchanges may return various error codes when a cancellation request fails (e.g., order not found, insufficient permissions, or temporary service errors). Robust bots must interpret these responses and decide whether to retry, ignore, or escalate the issue.

5. Rate Limiting and Throttling

Frequent cancellation requests can trigger rate limits or anti-abuse mechanisms on some exchanges. Bots must batch or pace cancellation requests to avoid being temporarily blocked or penalized.

Best Practices for Engineering Order Cancellation

Maintain Accurate Order State

  • Sync open orders frequently: Regularly fetch the list of open orders from the exchange to reconcile with the bot’s internal state.
  • Track order IDs: Use the unique IDs returned by the exchange for all cancellation requests.

Validate Before Canceling

  • Check order status: Before sending a cancellation, confirm that the order is still open and not already filled or canceled.
  • Filter by strategy logic: Only cancel orders that are outside the current desired ladder or are mispriced according to the latest strategy parameters.

Robust API Interaction

  • Handle errors gracefully: Implement logic to retry cancellations in the event of transient errors, and log permanent failures for review.
  • Respect rate limits: Throttle cancellation requests as needed to comply with exchange policies.

User Controls and Transparency

  • Manual cancellation options: Allow users to cancel individual orders or all open orders for a symbol directly from the interface.
  • Event logging: Record all cancellation attempts, successes, and failures for auditability and troubleshooting.

How Atlas LP Approaches Order Cancellation

Atlas LP is designed to provide robust, transparent order management for spot market making across multiple supported exchanges. Here’s how order cancellation is engineered within the Atlas LP platform:

  • Order Ladder Calculation: On each tick, Atlas LP computes the desired set of limit orders based on the strategy’s spread bands, order levels, and price bands. Any open order that does not match the current ladder (by price, side, or quantity) is marked for cancellation.

  • Selective Cancellation: The bot cancels only excess or mispriced orders, minimizing unnecessary API calls and reducing the risk of hitting rate limits.

  • Accurate State Sync: Open orders are regularly synced with the exchange, and recent fills are incorporated to keep the bot’s internal state accurate.

  • User-Initiated Actions: Users can cancel a specific open order or all open orders for a symbol directly from the bot page. Stopping a bot halts new order placement and allows for orderly cancellation of remaining orders.

  • Error Handling: If the exchange rejects credentials or a cancellation fails, Atlas LP stops the bot and displays an error status, preventing further unintended actions.

  • Audit and Monitoring: All bot events, including cancellations, are logged in the console for transparency. Daily snapshots of account asset value help users monitor the impact of order management decisions.

Common Pitfalls and How to Avoid Them

PitfallMitigation Strategy
Cancelling the wrong orderAlways use exchange-provided order IDs
API rate limit violationsThrottle requests and batch cancellations
Stale internal order stateSync open orders with the exchange frequently
Ignoring partial fillsReconcile fills before and after cancellation
Unhandled API errorsImplement robust error handling and logging

Conclusion

Reliable order cancellation is critical for safe and effective crypto market making. By engineering bots to maintain accurate order state, validate cancellations, handle API errors, and provide transparent controls, teams can reduce risk and improve liquidity outcomes. Atlas LP incorporates these best practices to help users manage spot liquidity efficiently across multiple exchanges.

For more on how Atlas LP enables secure, compliant, and transparent spot market making, see our 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.

← Back to blog

Frequently asked questions

Why is reliable order cancellation important for market making bots?

Reliable order cancellation prevents unwanted exposure, ensures accurate liquidity provision, and helps maintain compliance with exchange rules. It is essential for adapting to changing market conditions and managing risk.

How does Atlas LP handle order cancellation?

Atlas LP selectively cancels only excess or mispriced orders based on the current strategy. Open orders are regularly synced with the exchange, and users can manually cancel individual or all orders from the bot page.

What are common challenges in order cancellation?

Challenges include API latency, rate limits, partial fills, stale internal state, and handling API errors. Robust engineering is required to address these issues.

Can users manually cancel orders in Atlas LP?

Yes, users can cancel one open order or all open orders for a symbol directly from the Atlas LP bot page.

Does Atlas LP guarantee profit or trading volume?

No, Atlas LP does not guarantee returns, price increases, trading volume, or listings. It provides tools for genuine spot market making.

Related articles

Run your spot liquidity bot with clear controls

Connect an exchange API key, set your spread band and order levels, and monitor orders, fills and balances from one console.

Create an account