Skip to main content
An order names an outcome, a price and a quantity. A trading key signs it. The order trades that key’s subaccount.

Retries

clientId is a label, not an idempotency key. The exchange echoes it on the answer and on every open and fill. Use it to match an event to the place that caused it. The exchange never checks it for uniqueness.
A replayed place always places again. Send each order once. If you lose an answer, read the private stream before you resend. Match on clientId. No route cancels by clientId.

Batch

A batch is all or nothing. The exchange checks every order before it places any. One refused order refuses the batch, and the exchange places nothing. A refusal names every refused order in rejected, by its position in the request.
422
index is the order’s zero-based position in the batch you sent. reason is prose for a human, and it can change. Branch on the envelope’s code and on index. Fix the named orders. Then resend the batch. The exchange placed nothing, so the resend places every order. clientId is not an idempotency key, so give each order a fresh one before you resend.

A place is not a rest

Cancel

A 200 means the exchange queued the cancel. The cancel event on the private stream confirms that the order left the book. A batch cancel can cancel some orders and not others:
207

No amend

Cancel the order. Then place a replacement. The replacement joins the back of its price level. A fill can land between the cancel and the place. Size the replacement from the cancel event’s remaining. Give the replacement a fresh clientId before you send the cancel. See Order lifecycle.

Read

ORDER110 @ 0.670one open event · GET /v3/orders
FILL40 @ 0.670fee $0.00266 · remaining 70
FILL70 @ 0.665fee $0.00468 · remaining 0 → FILLED
POSITION110 @ 0.66682 avgcollateral $0.73350 · GET /v3/portfolio/positions