Skip to content

Preview Perps Order

Validates a proposed order against your live account state and returns a cost/margin preview. Nothing is placed — this is a read against the venue and your account.

Endpoint

Portfolio API: POST https://ddp.definitive.fi/v2/portfolio/perps/orders/preview

Organization API: Replace /v2/portfolio/ with /v2/organization/portfolios/{portfolioId}/. See Portfolio vs. Organization API.

Requires a WRITE-scoped API key (all POST endpoints do). Returns 503 on deployments where perps account reads are not yet enabled — see Availability.

Request Body

FieldTypeRequiredDescription
symbolstringYesMarket symbol, e.g. "native:BTC" — see Market Symbols
sidestringYes"buy" or "sell"
orderTypestringYes"market", "limit", "stop_market", "stop_limit", "take_profit_market", "take_profit_limit", "twap"
sizestringYesOrder size in the base asset
pricestringNoLimit price (limit-priced order types)
triggerPricestringNoTrigger price (stop/take-profit types)
reduceOnlybooleanNoRestrict the order to reducing the current position
leveragenumberNo1–100; defaults to the account's active leverage
takeProfitstringNoAttached take-profit price
stopLossstringNoAttached stop-loss price
twapDurationMinutesnumberNo5–1440; required for "twap"

Examples

const json = await AuthHelpers.signAndSend({
  path: "/v2/portfolio/perps/orders/preview",
  method: "POST",
  body: {
    symbol: "native:BTC",
    side: "buy",
    orderType: "limit",
    size: "0.01",
    price: "64000",
  },
  apiKey: process.env.API_KEY,
  apiSecret: process.env.API_SECRET,
});

Response

{
  validation: {
    canSubmit: true,
    reason: "ok"            // otherwise e.g. "insufficient-balance", "below-min-notional",
                            // "exceeds-max-size", with matching detail fields
  },
  preview: {
    fillPrice: 64000,
    notional: 640,
    estimatedFee: 0.096,
    appliedFeeRate: 0.00015,   // maker for limit-priced types, taker otherwise
    feeRates: { takerRate: 0.00045, makerRate: 0.00015 },
    marginRequired: 16,
    totalCost: 16.1,
    effectiveAvailable: 9837.76,
    releasedMargin: 0,
    offsetNotional: 0
  },
  feeRates: { takerRate: 0.00045, makerRate: 0.00015 }
}

validation.canSubmit: false comes with a reason and human-readable detail fields (e.g. minNotionalDisplay); the preview is still returned where computable.