Skip to content

Cancel many#

POST https://api.pro.anboto.xyz/api/v2/trading/order/cancelMany

This will initiate the order cancellations and set the status of all orders to pending cancel. For the finalized state call /order?orderId=xxx ApiKeyAuth required.

Body params#

orders array[CancelUpstreamOrderRequest] required
The list of parent cancellation requests

Headers#

Header
X-API-KEY string required
X-TIMESTAMP int64 ms required
X-SIGN string required
X-RECV-WINDOW int, default 5000

Responses#

200 Cancellation request processed and in progress.
401 Unauthorized, Invalid Signature
429 Rate limit exceeded, retry later

Response fields — OrderSummary#

order_id integer
The Anboto assigned order identifier
client_order_id string
A custom string to identify the order
Example: ABC-12345^12-10-23
status enum
The order status — PENDING_NEW, ACCEPTED, REJECTED, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELLED, PENDING_PAUSE, … (12 values)
created_at date-time required
The time in UTC when the order was created
Example: 2024-01-22T22:05:00Z
message string
Any additional information, usually if the order was rejected
error_code enum
The error code used to describe why an order was rejected. — OTHER, QUANTITY_EXCEED, AUTHENTICATION_ERROR, INSUFFICIENT_FUNDS, RATE_LIMIT_EXCEEDED, DDOS_PROTECTION, EXCHANGE_NOT_AVAILABLE, NETWORK_ERROR, … (34 values)
Example: INVALID_ORDER
body='{
  "orders": [
    {
      "order_id": 123456,
      "client_order_id": "xxx-yyy-zzzz"
    }
  ]
}'

curl -X POST "$BASE/api/v2/trading/order/cancelMany" \
  -H "X-API-KEY: $API_KEY" -H "X-TIMESTAMP: $ts" \
  -H "X-SIGN: $sign" \
  -H "Content-Type: application/json" -d "$body"
payload = {
  "orders": [
    {
      "order_id": 123456,
      "client_order_id": "xxx-yyy-zzzz"
    }
  ]
}

r = requests.post(f"{BASE}/api/v2/trading/order/cancelMany",
    data=json.dumps(payload)
    headers=signed_headers(payload))
print(r.json())
let payload = serde_json::json!({
  "orders": [
    {
      "order_id": 123456,
      "client_order_id": "xxx-yyy-zzzz"
    }
  ]
});

let resp = client
    .post(format!("{BASE}/api/v2/trading/order/cancelMany"))
    .headers(signed_headers(&payload))
    .json(&payload)
    .send()?;
println!("{}", resp.text()?);
payload := map[string]any{
    "orders": []any{
        map[string]any{
            "order_id": 123456,
            "client_order_id": "xxx-yyy-zzzz",
        },
    },
}
body, _ := json.Marshal(payload)

req, _ := http.NewRequest("POST", BASE+"/api/v2/trading/order/cancelMany", bytes.NewReader(body))
for k, v := range signedHeaders(string(body)) {
    req.Header.Set(k, v)
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
String jsonBody = mapper.writeValueAsString(payload);
HttpResponse<String> resp = client.send(
    signedPost("/api/v2/trading/order/cancelMany", jsonBody),
    HttpResponse.BodyHandlers.ofString());
const payload: CancelManyUpstreamOrdersRequest = {
  "orders": [
    {
      "order_id": 123456,
      "client_order_id": "xxx-yyy-zzzz"
    }
  ]
};

const res = await fetch(`${BASE}/api/v2/trading/order/cancelMany`, {
  method: "POST",
  headers: signedHeaders(payload),
  body: JSON.stringify(payload),
});
const data: OrderSummary = await res.json();
val jsonBody = mapper.writeValueAsString(payload)
val request = signedPost("/api/v2/trading/order/cancelMany", jsonBody)
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
std::string body = R"({
  "orders": [
    {
      "order_id": 123456,
      "client_order_id": "xxx-yyy-zzzz"
    }
  ]
})";

cpr::Response r = cpr::Post(
    cpr::Url{BASE + "/api/v2/trading/order/cancelMany"},
    signedHeaders(body),
    cpr::Header{{"Content-Type", "application/json"}},
    cpr::Body{body});
std::cout << r.text << std::endl;
const payload = {
  "orders": [
    {
      "order_id": 123456,
      "client_order_id": "xxx-yyy-zzzz"
    }
  ]
};

const res = await fetch(`${BASE}/api/v2/trading/order/cancelMany`, {
  method: "POST",
  headers: signedHeaders(payload),
  body: JSON.stringify(payload),
});
console.log(await res.json());

Response 200

{
  "order_id": 0,
  "client_order_id": "ABC-12345^12-10-23",
  "status": "PENDING_NEW",
  "created_at": "2024-01-22T22:05:00Z",
  "message": "string",
  "error_code": "OTHER"
}