Cancel All Orders
Cancel all open orders
info
- Support cancel orders by
symbol
/baseCoin
/settleCoin
. If you pass multiple of these params, the system will process one of param, which priority issymbol
>baseCoin
>settleCoin
. - NOTE: category=option, you can cancel all option open orders without passing any of those three params. However, for "linear" and "inverse", you must specify one of those three params.
- NOTE: category=spot, you can cancel all spot open orders (normal order by default) without passing other params.
info
Spot: classic account - cancel up to 500 orders; Unified account - no limit
Futures: classic account - cancel up to 500 orders; Unified account - cancel up to 500 orders
Options: Unified account - no limit
HTTP Request
POST /v5/order/cancel-all
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type |
symbol | false | string | Symbol name, like BTCUSDT , uppercase onlylinear &inverse : Required if not passing baseCoin or settleCoin |
baseCoin | false | string | Base coin, uppercase only
|
settleCoin | false | string | Settle coin, uppercase only
|
orderFilter | false | string |
|
stopOrderType | false | string | Stop order type Stop linear or inverse and orderFilter=StopOrder ,you can cancel conditional orders except TP/SL order and Trailing stop orders with this param |
info
The ack of cancel-all order request indicates that the request is successfully accepted. Please use websocket order stream to confirm the order status
Response Parameters
Parameter | Type | Comments |
---|---|---|
list | array | Object |
> orderId | string | Order ID |
> orderLinkId | string | User customised order ID |
success | string | "1": success, "0": fail |
Request Example
- HTTP
- Python
- Java
- .Net
- Node.js
POST /v5/order/cancel-all HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672219779140
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"category": "linear",
"symbol": null,
"settleCoin": "USDT"
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.cancel_all_orders(
category="linear",
settleCoin="USDT",
))
import com.bybit.api.client.restApi.BybitApiTradeRestClient;
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.trade.*;
import com.bybit.api.client.service.BybitApiClientFactory;
BybitApiClientFactory factory = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET");
BybitApiAsyncTradeRestClient client = factory.newAsyncTradeRestClient();
var cancelAllOrdersRequest = TradeOrderRequest.builder().category(ProductType.LINEAR).baseCoin("USDT").build();
client.cancelAllOrder(cancelAllOrdersRequest, System.out::println);
using bybit.net.api.ApiServiceImp;
using bybit.net.api.Models.Trade;
BybitTradeService tradeService = new(apiKey: "xxxxxxxxxxxxxx", apiSecret: "xxxxxxxxxxxxxxxxxxxxx");
var orderInfoString = await TradeService.CancelAllOrder(category: Category.LINEAR, baseCoin:"USDT");
Console.WriteLine(orderInfoString);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.cancelAllOrders({
category: 'linear',
settleCoin: 'USDT',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"list": [
{
"orderId": "1616024329462743808",
"orderLinkId": "1616024329462743809"
},
{
"orderId": "1616024287544869632",
"orderLinkId": "1616024287544869633"
}
],
"success": "1"
},
"retExtInfo": {},
"time": 1707381118116
}