Skip to content

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

ParameterTypeRequiredDescription
portfolioIdstringYesUUID of the portfolio
orderIdstringYesUUID 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 processing
  • ORDER_STATUS_ACCEPTED - Order is accepted and being processed
  • ORDER_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 executed
  • ORDER_STATUS_CANCELLED - Order is already cancelled
  • ORDER_STATUS_REJECTED - Order was rejected by the system
  • ORDER_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

  1. Check order status before attempting cancellation using Get Order Details
  2. Handle race conditions - orders may fill between status check and cancellation attempt
  3. Monitor order updates - use webhooks or polling to track order status changes
  4. Immediate cancellation - cancel as soon as possible if needed, as QuickTrade orders execute quickly
  5. 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