Cancelling orders

Introduction

Cancelling orders for a party on Vega can be done in three ways:

  • Cancel a single order on a market.
  • Cancel all orders on a single market.
  • Cancel all orders on all markets.

In a similar way to submitting an order, all cancellations must be prepared and signed before submitting to the Vega network. Orders can only be cancelled if they have a status which is active, not expired and not fully filled.

See the API reference to learn more about order status codes on Vega.

How do I cancel orders?

It is only possible to cancel orders for a party for which you have a public/private key pair.

Connect to a Vega API server, and cancel an order:

1. Log in to wallet and get public key

See the section on the Wallet service to learn how to log in, list keys and select a public key.

For a working wallet example used by this how-to guide, please visit the API Samples GitHub repo.

2. Compose an order cancellation message

Gitpod ready-to-code What’s Gitpod?

Cancel a single order
Cancel all orders on a market
Cancel all orders on all markets
Cancel a single order
Cancel all orders on a market
Cancel all orders on all markets
Cancel a single order
Cancel all orders on a market
Cancel all orders on all markets

3. Sign and send the transaction

Gitpod ready-to-code What’s Gitpod?

See also REST API reference for further query detail.

See also REST API reference for further query detail.

See also REST API reference for further query detail.

If successful, the response will include:

Field Description
signature A signed transaction message containing the cancellation data. Because propagate is set to true, the signed data will be automatically forwarded by the wallet server to a node. If you wish to manually submit the transaction you can do so with the data in signature (tx) and set propagate to false.
For full example code, please visit the repo on GitHub.

What’s next?