Order flow
The normal flow for one order is:
- Send
POST /trading/accounts/{account_id}/orderswith a newIdempotency-Keyandclient_order_id. - Read the
201response. It confirms command acceptance and contains the platform-generatedorder_idand the suppliedclient_order_id. It does not mean the order is resting or filled. - Receive
order_updateframes from/orders. Each frame contains the full order view, includingstatus,filled_qty, andstatus_reason. - Treat
FILLED,CANCELLED,EXPIRED, andREJECTEDas terminal states.
Request-body rules:
| Type | Side | price |
qty |
volume |
|---|---|---|---|---|
LIMIT |
any | required | required | forbidden |
MARKET |
BUY |
forbidden | forbidden | required budget |
MARKET |
SELL |
forbidden | required | forbidden |
tokenis required.BUY NOexecutes asSELL YES, andSELL NOexecutes asBUY YES; the matching engine uses one book ofYEScontracts.- Keep
client_order_idunique among active orders. Reusing old values makes client-ID targeting ambiguous, so the safest policy is never to reuse them. An amend does not change the ID. - Amend and cancel identify an order by
order_idorclient_order_idand requiremarket_idin the body. Preferorder_id. - Changing price or increasing quantity loses queue priority. Decreasing quantity at the same price preserves it.
- A command can be accepted by REST and later rejected by the engine. Rejected amend and cancel commands arrive as
order_rejectframes. DELETE /trading/markets/{market_id}/orderscancels the broker's resting orders on that market across all accounts. It returnsref_id; each resulting cancellation has the same value inlast_cmd_id_hex.
Idempotency and retries
Every state-changing POST, PATCH, and DELETE requires an Idempotency-Key.
- Generate a key for each logical command.
- Persist the key and exact request before sending it.
- On a timeout or retryable
5xx, resend the same request with the same key. - Never reuse the key with different content.
Interpret success codes according to the operation contract:
200or201normally means first acceptance for order commands.202means an idempotent replay for order commands, but it is also the normal first-acceptance response forPOST .../merge. Do not infer replay from the status code alone.- A successful command response confirms acceptance, not final execution.
Important errors:
400,404, or422: the request, identifier, or current resource state is invalid for that operation. Fix or reconcile before retrying.403: the broker is not permitted to perform the operation.409 idempotency_key_mismatch: the key was reused with different content. This is a client bug; do not retry.429: wait forRetry-After. Repeating an already recorded command with the same key and content does not consume command quota.503 outcome_unknown: the safe retry period has passed. Stop retrying the command and reconcile its resource state.- Other retryable
5xx: use bounded backoff and preserve the same key and request bytes.
Idempotency context has a sliding TTL of one hour from the latest request carrying that key. Every repeat refreshes the TTL, including a payload mismatch. Do not treat expiration as permission to submit the logical command again.