SnapshotQuoteRequest or SubscribeQuoteRequest

Note

For a more in depth documentation, you should check the comments from the protobuf file.

Note

QST server allows clients to subscribe only to active instruments (that are not expired).

If client asks only for snapshots, QST server provides the snapshots for all active instruments and in addition to this for TOM it provides snapshots also for expired instruments, for DOM it will return error if instrument is expired.

Purpose

SnapshotQuoteRequest is used to obtain snapshots for specific instruments.

SubscribeQuoteRequest is used to obtain snapshots for specific instruments and also subscribe the client to those instruments which will generate AsyncQuotes.

The only difference between the contents of these requests is that they have different names and will also generate responses(that contain the snapshots) with different names.

Supported subscription types are the following:

  • TOM - Subscribe to all market data statistics for the current trading day(High, Low, Open, Close prices, Volume, Open Interest, Current Trading Day, etc.), which can be found in the TomComplete message. There are two types of tom subscriptions:

    • TRADES_ONLY - The client will only receive trades, without the other market data statistics.

    • TRADES_BIDS_ASKS - The client will all market data statistics.

  • OUTRIGHT DOM - Subscribe to DOM outright, which contains the depth of market book of orders for ask and bid for a specific instrument; and the maximum market depth.

  • IMPLIED DOM - Subscribe to DOM implied, which contains the depth of market book of orders for ask and bid for a specific instrument; and the maximum market depth.

  • COMBINED DOM WIP - this is a work in progress.

Note

To usubscribe from a instrument, after a SubscribeQuoteRequest, the client should send an UnsubscribeQuoteRequest.

Note

  • If multiple SubscribeQuoteRequests, with the same subscription type are sent for the same instrument, the last request will overwrite all the previous ones. As a result, in order to change the subscription level (for example from DOM to TOM) a client should simply send another SubscribeQuoteRequest with the new level for the same instrument ID.

  • If multiple QuoteSubscriptionRecord of the same SubscribeQuoteRequest, with different subscription type are sent for the same instrument, we will subscribe to the sum of those subtypes.

  • If the client subscribes in the same request to tom_0 and tom_1, the last one will be kept.


How do subscriptions work?

The client can subscribe to an instrument using 4 subscription types(check the subscription types from above).

Let’s take the following scenario:

  • Client sends one SubscribeQuoteRequest for instrument 1 that contains the following subscription types: TOM``(``TRADES_ONLY) and OUTRIGHT DOM.

  • Client sends one SubscribeQuoteRequest for instrument 1 that contains the following subscription type: IMPLIED DOM.

This means that the client is subscribed to instrument 1 to TOM, OUTRIGHT DOM and IMPLIED DOM. If the client wants to unsubscribe from the whole instrument, it should send an UnsubscribeQuoteRequest that contains the following unsubscribe types: TOM, DOM_OUTRIGHT and DOM_IMPLIED.

The client can also unsubscribe partially from an instrument, for example the client can remove the TOM subscription from instrument 1 from above, which will result in having a subscription to only DOM_OUTRIGHT and DOM_IMPLIED. To do this, the client should send an UnsubscribeQuoteRequest that contains the following unsubscribe type: TOM.

The client can update it’s subscription to TOM, for example the client might want TRADES_BIDS_ASKS for the TOM subscription instead of TRADES_ONLY. To do this, the client should send a SubscribeQuoteRequest for instrument 1 that contains the TOM subscription type with TRADES_BIDS_ASKS tom level. This request will override the previous TOM subscription, the other ones(DOM_OUTRIGHT and DOM_IMPLIED) remain unchanged.


Requests examples

SnapshotQuoteRequest

const payload = {
  request_id: 1,
  snapshot_quote: { // this is different from SubscribeQuoteRequest
    request_records: [{ // this is different from SubscribeQuoteRequest
      instrument_id: 1,
      subscription_types: [{
        dom: {
          type: 0,
          level: -1
        }
      },
      {
        dom: {
          type: 1,
          level: -1
        }
      }]
    }, {
      instrument_id: 2,
      subscription_types: [{
        tom: {
          level: 0
        }
      }]
    }]
  }
};

SubscribeQuoteRequest

const payload = {
  request_id: 1,
  subscribe_quote: { // this is different from SnapshotQuoteRequest
    quote_subscription_records: [{ // this is different from SnapshotQuoteRequest
      instrument_id: 1,
      subscription_types: [{
        dom: {
          type: 0,
          level: -1
        }
      },
      {
        dom: {
          type: 1,
          level: -1
        }
      }]
    }, {
      instrument_id: 2,
      subscription_types: [{
        tom: {
          level: 0
        }
      }]
    }]
  }
};

Responses

Valid

The server will respond with a SnapshotQuoteResponse (SubscribeQuoteResponse) that will contain one or more SnapshotResponseRecord. The SnapshotResponseRecord can contain one of the following fields:

  • Snapshot - containing the snapshot for an instrument.

  • SnapshotError - containing an error regarding an invalid instrument id for which the server couldn’t generate a snapshot.

The SnapshotError may contain one of the following error messages:

  • No subscription type was provided - The request doesn’t contain the subscription_types group or the group is empty or the group contains an empty element.

  • Couldn’t identify the instrument - The instrument id that the client provided is invalid, or the user has no rights to that instrument.


Async Quotes

If the client used the SubscribeQuoteRequest request, the server will respond with a SubscribeQuoteResponse and will also generate AsyncQuotes.


ErrorMessage

The server will respond with an ErrorMessageResponse with the following error message:

  • No quote subscription records were provided - If the request doesn’t contain request_records gropup(quote_subscription_records) or the group is empty or the group contains an empty element.