Order references

Order references

Introduction

When submitting orders to Vega, the order messages must be signed and sent to the Vega blockchain in the form of transactions. Validation checks are performed at multiple stages in the pipeline, for example, before consensus and after consensus.

An order is assigned a unique identifier at the point it’s accepted into the core matching engine, this is after consensus on the blockchain. Therefore users are required to keep track of their orders using something called the order reference. The order reference is currently a UUID and returned to the user in the response from calling the prepareSubmitOrder method.

How do I find my order after submission?

There are two options, query for the reference (found in the submitId field returned after calling prepareSubmitOrder) or if using gRPC or GraphQL subscribe to a stream of orders and wait for your order to arrive on the stream with the unique order identifier attached.

Vega aims to produce a block every 1 second, which means that it may take 1+ seconds before your order is processed by the blockchain and made available through the API.

Query for an order by reference

Connect to a Vega API server, and request for an order by reference.

Gitpod ready-to-code What’s Gitpod?

See also wallet REST API reference for further query detail.

See also wallet REST API reference for further query detail.

Make sure vegaapiclient is installed (from PyPI):

pip install --upgrade Vega-API-client

This Python snippet code shows how to query for an order by reference:

See also gRPC API reference for further query detail.

If successful, the response will include:

Field Description
order If found, an order record matching the reference provided will be returned. If there is no matching order for reference, or the order with reference has not been processed completely by Vega, then no records will be returned.
For full example code, please visit the repo on GitHub.

Subscribe to a stream of orders for a party

Connect to a Vega API server, and request to stream of orders:

Gitpod ready-to-code What’s Gitpod?

Make sure graphqurl is installed (from GitHub):

npm install -g graphqurl

This snippet code shows how to subscribe to a stream of orders for a party:

See also GraphQL API reference for further query detail.

Make sure vegaapiclient is installed (from PyPI):

pip install --upgrade Vega-API-client

This Python snippet code shows how to receive a stream of *orders for a party:

See also gRPC API reference for further query detail.

If successful, the response will include:

Field Description
orders A stream of zero or more orders will be returned, filtering the orders stream on order reference will attempt to find an order by reference. Note: There is currently no direct order by reference filter available on streams.
For full example code, please visit the repo on GitHub.

What’s next?