What is the Cancel On Disconnect All Open Orders (dead-man-switch) feature?
The Cancel On Disconnect All Open Orders function, also known as “dead-man-switch”, acts as a safety mechanism for API traders in the event of unexpected network connection issues or upgrades that require exchange downtime. This feature allows traders to ensure stale orders are cancelled if they experience a connection issue, giving them the confidence to provide tighter bid-ask spreads, larger quote sizes, and more time in the market.
How Does the Cancel On Disconnect All Open Orders (dead-man-switch) feature work?
The dead-man-switch will cancel all of an API trader's open orders when it detects a network disconnection - either from the user or within our internal systems. Internally, this feature uses health checks on our services to determine network disconnection. Externally, this feature functions by using a countdown timer set and reset by the API trader in each market individually, activating if the timer is not reset and reaches zero. Once the timer reaches zero, the server will automatically cancel all open orders of the trader in the specified market.
Once the system receives a reset countdown request from the user, it will reset the countdown time. In the absence of a reset countdown request, the system will interpret this as the user getting disconnected from the server and will also carry out cancellations on all specified markets.
- User inputs a market (e.g. BTC-PERP) and a countdown time parameter in milliseconds (e.g. 10000 for 10sec) Note: If the countdown time parameter is inputted as 0, the countdown will be disabled for that market.
- User will send a request to reset the countdown by calling the endpoint at specific intervals (e.g. every 3 seconds) to the server.
- The server will respond with a response containing two arrays acceptedToReset and failedReset specifying the markets for which the countdown time has been reset and failed respectively.
- If the server does not receive a reset countdown request from the user, the countdown will eventually expire and it will interpret this as a disconnection from the server and will cancel all open orders for that market.
- If the server receives a reset countdown request from the user, the countdown will be reset and the server will continue to wait for the next reset countdown request or expiration of the current countdown.
- In the case of downtime on any service related to Order Management or the market becoming inactive, the server will not accept countdown reset requests. All countdown reset requests for that market will be rejected, added to the failedReset array in the response, and the orders will be canceled once the timer expires.
- In case of downtime on the dead-man-switch, the server will not be able to process the countdown reset requests, and on restart of the service, the server will cancel orders for the markets for which the countdown has expired.