Orders
Cancel orders in bulk
Cancels the working orders of an account in one scope: one instrument,
one market, or the whole account when neither is set.
- Narrow it further with
label,sideandorderFilter. - Without
labelit also cancels orders placed by hand and by other scripts.
Safe to retry: the second time there is nothing left to cancel.
202 means the cancellation was accepted for asynchronous processing. The
outcome arrives on the events stream as a notification frame
(cancelAllOrders).
POST
/
api
/
v1
/
trading
/
order
/
cancel-all
Cancel orders in bulk
curl --request POST \
--url https://public-api.charting.com/api/v1/trading/order/cancel-all \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-SIGNATURE: <api-key>' \
--header 'X-API-TIMESTAMP: <api-key>' \
--data '
{
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1"
}
'import requests
url = "https://public-api.charting.com/api/v1/trading/order/cancel-all"
payload = {
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1"
}
headers = {
"X-API-KEY": "<api-key>",
"X-API-TIMESTAMP": "<api-key>",
"X-API-SIGNATURE": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-KEY': '<api-key>',
'X-API-TIMESTAMP': '<api-key>',
'X-API-SIGNATURE': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
accountId: '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
connectorCode: 'binance_usdm',
instrument: {exchange: 'CXBNCE', symbol: 'BTC/USDT'},
label: 'grid-btc-1'
})
};
fetch('https://public-api.charting.com/api/v1/trading/order/cancel-all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public-api.charting.com/api/v1/trading/order/cancel-all",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
'connectorCode' => 'binance_usdm',
'instrument' => [
'exchange' => 'CXBNCE',
'symbol' => 'BTC/USDT'
],
'label' => 'grid-btc-1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-SIGNATURE: <api-key>",
"X-API-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.charting.com/api/v1/trading/order/cancel-all"
payload := strings.NewReader("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("X-API-TIMESTAMP", "<api-key>")
req.Header.Add("X-API-SIGNATURE", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://public-api.charting.com/api/v1/trading/order/cancel-all")
.header("X-API-KEY", "<api-key>")
.header("X-API-TIMESTAMP", "<api-key>")
.header("X-API-SIGNATURE", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.charting.com/api/v1/trading/order/cancel-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["X-API-TIMESTAMP"] = '<api-key>'
request["X-API-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\"\n}"
response = http.request(request)
puts response.read_body{
"requestId": "<string>"
}{
"error": {
"code": "invalid_argument",
"message": "field \"price\" is required for a limit order"
}
}{
"error": {
"code": "unauthenticated",
"message": "invalid API key or signature"
}
}{
"error": {
"code": "permission_denied",
"message": "permission denied"
}
}{
"error": {
"code": "not_found",
"message": "account not found"
}
}{
"error": {
"code": "rate_limited",
"message": "rate limit exceeded"
}
}Authorizations
Body
application/json
Scope: one instrument, one market, or neither for every order of
the account. Not both.
Was this page helpful?
⌘I
Cancel orders in bulk
curl --request POST \
--url https://public-api.charting.com/api/v1/trading/order/cancel-all \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-API-SIGNATURE: <api-key>' \
--header 'X-API-TIMESTAMP: <api-key>' \
--data '
{
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1"
}
'import requests
url = "https://public-api.charting.com/api/v1/trading/order/cancel-all"
payload = {
"accountId": "4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45",
"connectorCode": "binance_usdm",
"instrument": {
"exchange": "CXBNCE",
"symbol": "BTC/USDT"
},
"label": "grid-btc-1"
}
headers = {
"X-API-KEY": "<api-key>",
"X-API-TIMESTAMP": "<api-key>",
"X-API-SIGNATURE": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-API-KEY': '<api-key>',
'X-API-TIMESTAMP': '<api-key>',
'X-API-SIGNATURE': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
accountId: '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
connectorCode: 'binance_usdm',
instrument: {exchange: 'CXBNCE', symbol: 'BTC/USDT'},
label: 'grid-btc-1'
})
};
fetch('https://public-api.charting.com/api/v1/trading/order/cancel-all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://public-api.charting.com/api/v1/trading/order/cancel-all",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => '4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45',
'connectorCode' => 'binance_usdm',
'instrument' => [
'exchange' => 'CXBNCE',
'symbol' => 'BTC/USDT'
],
'label' => 'grid-btc-1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>",
"X-API-SIGNATURE: <api-key>",
"X-API-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://public-api.charting.com/api/v1/trading/order/cancel-all"
payload := strings.NewReader("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("X-API-TIMESTAMP", "<api-key>")
req.Header.Add("X-API-SIGNATURE", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://public-api.charting.com/api/v1/trading/order/cancel-all")
.header("X-API-KEY", "<api-key>")
.header("X-API-TIMESTAMP", "<api-key>")
.header("X-API-SIGNATURE", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public-api.charting.com/api/v1/trading/order/cancel-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["X-API-TIMESTAMP"] = '<api-key>'
request["X-API-SIGNATURE"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"accountId\": \"4b8e2f6a-91c3-4d57-a0e8-3f1c7b9d2e45\",\n \"connectorCode\": \"binance_usdm\",\n \"instrument\": {\n \"exchange\": \"CXBNCE\",\n \"symbol\": \"BTC/USDT\"\n },\n \"label\": \"grid-btc-1\"\n}"
response = http.request(request)
puts response.read_body{
"requestId": "<string>"
}{
"error": {
"code": "invalid_argument",
"message": "field \"price\" is required for a limit order"
}
}{
"error": {
"code": "unauthenticated",
"message": "invalid API key or signature"
}
}{
"error": {
"code": "permission_denied",
"message": "permission denied"
}
}{
"error": {
"code": "not_found",
"message": "account not found"
}
}{
"error": {
"code": "rate_limited",
"message": "rate limit exceeded"
}
}