Set Disconnect Cancel All
What is Disconnection Protect (DCP)?
Based on the websocket private connection and heartbeat mechanism, Bybit provides disconnection protection function. The timing starts from the first disconnection. If the Bybit server does not receive the reconnection from the client for more than 10 (default) seconds and resumes the heartbeat "ping", then the client is in the state of "disconnection protect", all active futures / spot / option orders of the client will be cancelled automatically. If within 10 seconds, the client reconnects and resumes the heartbeat "ping", the timing will be reset and restarted at the next disconnection.
How to enable DCP
If you need to turn it on/off, you can contact your client manager for consultation and application. The default time window is 10 seconds.
Applicable
Effective for Inverse Perp / Inverse Futures / USDT Perp / USDC Perp / USDC Futures / Spot / options (UTA2.0)
Effective for USDT Perp / USDC Perp / USDC Futures / Spot / options (UTA1.0)
After the request is successfully sent, the system needs a certain time to take effect. It is recommended to query or set again after 10 seconds
- You can use this endpoint to get your current DCP configuration.
- Your private websocket connection must subscribe "dcp" topic in order to trigger DCP successfully
HTTP Request
POST /v5/order/disconnected-cancel-all
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
product | false | string | OPTIONS (default), DERIVATIVES , SPOT |
timeWindow | true | integer | Disconnection timing window time. [3 , 300 ], unit: second |
Response Parameters
None
Request Example
- HTTP
- Python
- Java
- Node.js
POST v5/order/disconnected-cancel-all HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1675852742375
X-BAPI-RECV-WINDOW: 50000
Content-Type: application/json
{
"timeWindow": 40
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.set_dcp(
timeWindow=40,
))
import com.bybit.api.client.config.BybitApiConfig;
import com.bybit.api.client.domain.trade.request.TradeOrderRequest;
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.trade.*;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET", BybitApiConfig.TESTNET_DOMAIN).newTradeRestClient();
var setDcpOptionsRequest = TradeOrderRequest.builder().timeWindow(40).build();
System.out.println(client.setDisconnectCancelAllTime(setDcpOptionsRequest));
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.setDisconnectCancelAllWindow('option', 40)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "success"
}