Skip to main content

Cancel Order

Cancel an existing trade order.

Endpoint

POST /api/v3/tradeOrder/cancel

Description

Cancels an open trade order. Only orders with status OPEN or PENDING can be cancelled.

Authentication

Requires Bearer token authentication.

Authorization: Bearer {access_token}

Request Body

FieldTypeRequiredDescription
tradeOrderIdstringYesID of the order to cancel

Response

Returns the cancelled trade order object.

FieldTypeDescription
tradeOrderIdstringOrder identifier
tradingAccountIdstringTrading account ID
venuestringExchange venue
instrumentIdstringInstrument identifier
orderSidestringOrder side
orderTypestringOrder type
statusstringOrder status (CANCELLED)
quantitystringOriginal order quantity
executedQuantitystringQuantity filled before cancellation
cancelledAtintegerCancellation timestamp (milliseconds)

Usage

import requests

headers = {"Authorization": f"Bearer {access_token}"}

response = requests.post(
"https://cadenza-api-uat.algo724.com/api/v3/tradeOrder/cancel",
headers=headers,
json={
"tradeOrderId": "770e8400-e29b-41d4-a716-446655440002"
}
)

cancelled_order = response.json()["data"]
print(f"Order {cancelled_order['tradeOrderId']} status: {cancelled_order['status']}")
curl -X POST https://cadenza-api-uat.algo724.com/api/v3/tradeOrder/cancel \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json" \
-d '{"tradeOrderId": "770e8400-e29b-41d4-a716-446655440002"}'

Example Response

{
"data": {
"tradeOrderId": "770e8400-e29b-41d4-a716-446655440002",
"tradingAccountId": "550e8400-e29b-41d4-a716-446655440000",
"venue": "BINANCE",
"instrumentId": "BINANCE:BTC/USDT",
"baseAsset": "BTC",
"quoteAsset": "USDT",
"orderSide": "BUY",
"orderType": "LIMIT",
"timeInForce": "GTC",
"status": "CANCELLED",
"limitPrice": "50000.00",
"quantity": "0.001",
"executedQuantity": "0",
"executedCost": "0",
"createdAt": 1703052635110,
"updatedAt": 1703052700000,
"cancelledAt": 1703052700000
},
"success": true,
"errno": 0,
"error": null
}

Error Responses

HTTP CodeErrorDescription
400Invalid requestMissing order ID
401UnauthorizedInvalid or expired access token
404Not foundOrder not found
400Cannot cancelOrder already filled or cancelled

Example Error

{
"data": null,
"success": false,
"errno": -111001,
"error": "Order is already filled and cannot be cancelled"
}

Notes

  • Only OPEN or PENDING orders can be cancelled
  • Partially filled orders can be cancelled (unfilled portion is cancelled)
  • The executedQuantity shows how much was filled before cancellation
  • Cancellation is processed by the exchange and may take a moment
  • Use the WebSocket API for real-time cancellation confirmation