Skip to content
All library documents

Handling Connection and Order Errors in a Live Grid Trading Bot

Code Stratmill research code

Summary

This example shows how a live grid trading bot can respond to errors while trading SOLUSDT on a futures venue. Its handler distinguishes interrupted connections, critical connection failures, order errors, and custom error codes. It logs connection and order problems, and turns custom code 1000 into a bot error that aborts the connection. The example also configures a grid strategy with spread, interval, size, and position limits, then closes the bot after the strategy finishes.

The code illustrates error routing and one explicit shutdown condition; it provides no operating results or recovery policy. It does not explain the meaning or source of the custom code, how transient failures are retried, or how orders and positions are reconciled after disconnection. The grid parameters are illustrative configuration, not evidence that the strategy is profitable or safe. Traders adapting this pattern would need venue-specific error semantics and a broader recovery plan.

Key ideas

  • A live bot can route different connection and order failures through a shared error handler.
  • Connection interruptions and critical connection errors are logged separately.
  • Order error details are logged when supplied as strings or maps.
  • A designated custom error code is converted into a bot error to abort the connection.
  • The example gives no retry, reconciliation, or strategy performance evidence.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.