Skip to main content

Amending an existing order

Cross-Session Amending: Orders can be amended from a different SBE session than the one that submitted them. An order submitted on gateway side A can be amended on side B of the same pair.Response Routing: When those sessions differ, AmendOrderResponse is delivered to both the session that sent the AmendOrderRequest and the session that submitted the order. Fills stay on the submitting session. See Cross-session acknowledgements.

Cross-session acknowledgements

On a hot-hot A/B gateway pair, an amend or cancel can be sent from the side that did not place the order. Amend. When the requesting session and the submitting session differ, AmendOrderResponse is delivered to both. The matching-engine event carries two session stamps: the session that submitted the order, and the session that sent the request. Each gateway forwards the acknowledgement to its own session. Both copies share clientOrderId, orderId, and correlationId. The per-session sequence number differs. Dedupe the copies by correlationId and orderId across the two sessions. Cancel. The session that sends the cancel receives CancelOrderResponse. When that session is not the one that submitted the order, and the submitting session has negotiated schema version 17 or later, the submitting session receives an unsolicited OrdersCanceled (310). Schema version 17 is additive and backward-compatible: the OrdersCanceled layout is unchanged. Sessions negotiated below 17 keep the previous routing, with CancelOrderResponse delivered to both sessions. See Cancelling an Order. Fills are delivered to the session that submitted the order. A fill carries that submitting session only, so after an amend sent on the other side the fill still arrives on the owning session. A later amend follows the same split as above. A later cancel from another session again sends CancelOrderResponse to the requester and OrdersCanceled to the owner. Any fill stays on the owning session.

Pending amend limit

The number of unacknowledged amend (replace) requests per order is capped. An amend counts as pending from the time the exchange receives it until its AmendOrderResponse or AmendOrderReject is generated: Once the cap is reached, any further amend on that order (the 5th for a normal order, the 2nd for an OCO or reduce-only order) is rejected with AmendOrderReject reason 19 (TOO_MANY_PENDING_REPLACES) until one of the pending amends is acknowledged. This cap applies per order, not per session or connection: it is independent of the gateway rate limits and is not a gateway-side concurrency limit. OCO and per-order reduce-only orders originate on the other Deribit APIs (see Placing a New Order); the tighter cap applies to those orders regardless of which API amends them.

AmendOrderRequest (110)

Request to change the modifiable fields of an existing order.
Null values: Some optional fields use NULL_LONG / NULL_QUANTITY (0x8000000000000000L) as a sentinel to indicate “not set”. For example, set displayAmount = NULL_QUANTITY to keep the order non-iceberg.
The table below outlines the content of field 7 (flags) of AmendOrderRequest.
No reduce-only flag: reduce-only cannot be set per order in SBE, on amend or on submit. See Placing a New Order for the alternatives.

AmendOrderResponse (210)

Response to confirm an AmendOrderRequest was successful, sent from the exchange to the client. When the amend is sent from a different session than the one that submitted the order, this response is delivered on both sessions. See Cross-session acknowledgements. Any immediate fills generated by the AmendOrderRequest will be included in the AmendOrderResponse and will NOT be sent additionally in an OrderUpdate. If the amendment causes the order to aggress and it is speed bumped, the AmendOrderResponse is sent immediately with orderState = 4 (queued). Once the speed bump period expires, an unsolicited OrderPlaced message is sent. See Speed Bumps for details.

AmendOrderReject (212)

Reject generated in case an AmendOrderRequest is unsuccessful.