Skip to content

Submit Order

Submits a trade order using a previously obtained quote. The order will be executed according to the quote parameters and current market conditions.

Request URL

POST https://ddp.definitive.fi/v2/organization/portfolios/{portfolioId}/trade

Path Parameters

ParameterTypeRequiredDescription
portfolioIdstringYesUUID of the portfolio

Request Body

FieldTypeRequiredDescription
externalOrderRequestobjectYesOriginal order request (without quote details)
quoteIdstringYesQuote ID from the quote response

Example

// First, request a quote
const quoteResponse = await AuthHelpers.signAndSend({
  path: "/v2/organization/portfolios/00000000-0000-0000-0000-000000000001/trade/quote",
  method: "POST",
  body: {
    type: "market",
    chain: "ethereum",
    targetAsset: "...",
    contraAsset: "...",
    qty: "1000",
    orderSide: "buy",
    slippageTolerance: "0.01",
    maxPriceImpact: "0.01"
  },
  apiKey: process.env.API_KEY,
  apiSecret: process.env.API_SECRET,
});
 
// Extract the quote ID and original order request
const { quote: quoteDetails, ...externalOrderRequest } = quoteResponse;
const quoteId = quoteDetails.id;
 
// Then, submit the order
const orderResponse = await AuthHelpers.signAndSend({
  path: "/v2/organization/portfolios/00000000-0000-0000-0000-000000000001/trade",
  method: "POST",
  body: {
    externalOrderRequest,
    quoteId
  },
  apiKey: process.env.API_KEY,
  apiSecret: process.env.API_SECRET,
});
console.log(orderResponse);

Response

{
  "orderId": "00000000-0000-0000-0000-000000000005"
}

Notes

  • Quotes are short-lived and should be submitted immediately
  • If the quote expires or market conditions change, submission may fail
  • The externalOrderRequest should be the original order request without the quote details
  • The quoteId is found in the quote.id field of the quote response

Order Status

After submission, orders may move through the following statuses:

StatusDescription
submittedOrder has been received and is being processed
pendingOrder is waiting for execution conditions
partially_filledSome of the order has been executed
filledThe order has been fully executed
cancelledThe order was cancelled (manually or system-triggered)
failedExecution failed due to price impact, slippage, or technical error
expiredThe order expired before execution