Cancel QuickTrade Order
Cancel an active QuickTrade order that has not yet been fully executed via the Organization API. Only orders with status ORDER_STATUS_PENDING
, ORDER_STATUS_ACCEPTED
, or ORDER_STATUS_PARTIALLY_FILLED
can be cancelled. See Order Statuses for a complete reference of all available statuses.
Request URL
DELETE https://ddp.definitive.fi/v2/organization/portfolios/{portfolioId}/quicktrade/{orderId}
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
portfolioId | string | Yes | UUID of the portfolio |
orderId | string | Yes | UUID of the order to cancel |
Example
const json = await AuthHelpers.signAndSend({
path: "/v2/organization/portfolios/00000000-0000-0000-0000-000000000001/quicktrade/00000000-0000-0000-0000-000000000005",
method: "DELETE",
organizationId: "00000000-0000-0000-0000-000000000000",
apiKey: process.env.ORG_API_KEY,
apiSecret: process.env.ORG_API_SECRET,
});
console.log(json);
Response
{
success: true,
message: "Order cancelled successfully"
}
Cancellable Order Statuses
QuickTrade orders can be cancelled when they have one of these statuses:
ORDER_STATUS_PENDING
- Order is queued for processingORDER_STATUS_ACCEPTED
- Order is accepted and being processedORDER_STATUS_PARTIALLY_FILLED
- Order is partially executed
Non-Cancellable Order Statuses
Orders cannot be cancelled when they have these statuses:
ORDER_STATUS_FILLED
- Order is completely executedORDER_STATUS_CANCELLED
- Order is already cancelledORDER_STATUS_REJECTED
- Order was rejected by the systemORDER_STATUS_TERMINATED
- Order was terminated
QuickTrade vs Regular Trade Cancellation
QuickTrade cancellation works the same as regular trade cancellation, but with some key differences:
- Speed: QuickTrade orders may execute faster, leaving less time for cancellation
- Atomic execution: QuickTrade orders go through quote-and-execute flow internally
- Higher priority: QuickTrade orders may have higher execution priority
- Organization-level: Uses organization API credentials and permissions
Multi-Portfolio Management
Organizations can cancel QuickTrade orders across multiple portfolios by specifying the appropriate portfolioId
in the URL path. Each portfolio maintains its own order history and permissions.
Error Responses
Order Not Found
{
"error": "Order not found",
"code": "ORDER_NOT_FOUND"
}
Order Already Cancelled
{
"error": "Order already cancelled",
"code": "ORDER_ALREADY_CANCELLED"
}
Order Already Filled
{
"error": "Order already filled",
"code": "ORDER_ALREADY_FILLED"
}
Order Cannot Be Cancelled
{
"error": "Order cannot be cancelled",
"code": "ORDER_NOT_CANCELLABLE"
}
Portfolio Access Denied
{
"error": "Access denied to portfolio",
"code": "PORTFOLIO_ACCESS_DENIED"
}
Best Practices
- Check order status before attempting cancellation using Get Order Details
- Handle race conditions - orders may fill between status check and cancellation attempt
- Monitor order updates - use webhooks or polling to track order status changes
- Immediate cancellation - cancel as soon as possible if needed, as QuickTrade orders execute quickly
- Portfolio validation - ensure the organization has access to the specified portfolio
References
Notes
- Cancellations are final and cannot be undone
- Partial fills cannot be reversed - only the remaining quantity can be cancelled
- Network delays may affect cancellation success for fast-executing orders
- Organization-level permissions apply to all portfolio operations