Skip to main content

Atomic Amends

· 3 min read

Fast, single-transaction amend endpoints are now available enabling clients to modify order parameters in-place, keeping queue priority within the book.

Revisiting Edit Transactions

The editOrder endpoints are implemented using a cancel-new transaction model in the engine. This offers an effective and clean model for adjusting many of the core order attributes but also has some disadvantages.

The cancel-new model has multiple phases, i.e. a cancel phase, a creation phase for a new order and a copy phase for order attributes. Latency is introduced as the phases need validation and persistence. New order identifiers are created and linked between the orders.

There are some caveats in behaviour because the cancel-phase loses some useful order state, i.e. fill information for any executions are attached to the previous order and cannot be copied to the new one.

To summarize, from a client perspective:

  • Small latency is introduced due to multiple phases of processing and persistence.
  • The client needs to chain order identifiers to track changes to an order.
  • Orders always lose priority in the price queue.
  • The loss of fill information on the order makes the transaction difficult to use when trading around the market price.

Introducing Atomic Amend Transactions

The new amend order model is a single phase transaction, the order parameters are modified in-place within the book.

New Behaviours

A single order will be maintained across the lifetime of amend transactions. Therefore, orders will:

  • Keep the same order identifiers assigned by Kraken and/or client.
  • Keep the execution information on the order for any previous fills.
  • Keep queue priority in the order book where possible.

Some other beneficial behaviours have been added:

  • Amending down order quantity to below the filled quantity is accepted and the order will be amended to match the filled quantity.
  • Trigger order types can be amended in either the triggered or untriggered state.

For the full detail on keeping queue priority and amending iceberg orders, see the atomic amend guide.

Performance

From a performance perspective, there are some significant gains. Since there is a single phase instead of multiple phases:

  • Atomic amends are faster than edit transactions within the engine due to a reduction in transaction logging.
  • Given the efficiency increase, higher transaction rate limits are available on atomic amends.
  • Due to the better handling of race conditions, systematic clients are no longer required to initiate their own cancel-new transactions therefore reducing risk, number of transactions, io and latency.

FIX Protocol

Kraken FIX API has added the Replace Request (35=G) transaction message based the atomic amend model. This enables clients to amend the orders using FIX and benefit from the improved performance / rate limits.

Example

Scenario: simple price amend with client order identifier.

{
"method": "amend_order",
"params": {
"cl_ord_id": "btc-240720-87302",
"limit_price": 690794,
"token": "ikrPacc6HFPRn4vwES2hEzERRe71SVF4tmSbmpmHLGQ"
}
}

API Support

The amend transactions are supported in the following APIs:

The amend history for an order can be retrieved using the REST /OrderAmends endpoint.