For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 3

Does the "ID" need to match the reply & request?

Hi,

When receiving a request from the Chain Ric, what does the "ID" field refer to, does it need to match the "ID" field in the batch request of all the LONKLINK's as well? Right now I did match them because I found this in the doc ID = "Integer value(s) representing the event stream. It can also be used to match the request and responses."


Received:

  
                
  1.  [{
  2. "ID":4,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"0#2CCM:"},"State":{"Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBZyPA","SeqNumber":143,"Fields":{"PROD_PERM":6723,"RDNDISPLAY":219,"DSPLY_NAME":"BMF CORN","RDN_EXCHID":"BMF","CURRENCY":"BRL","REF_COUNT":8,"RECORDTYPE":152,"BCAST_REF":"COF","LONGLINK1":"2CCMH23","LONGLINK2":"2CCMK23","LONGLINK3":"2CCMN23","LONGLINK4":"2CCMU23","LONGLINK5":"2CCMX23","LONGLINK6":"2CCMF24","LONGLINK7":"2CCMH24","LONGLINK8":"2CCMU24","LONGLINK9":null,"LONGLINK10":null,"LONGLINK11":null,"LONGLINK12":null,"LONGLINK13":null,"LONGLINK14":null,"LONGPREVLR":null,"LONGNEXTLR":null,"PREF_DISP":1482,"PREF_LINK":null,"DSPLY_NMLL":null,"RDN_EXCHD2":"BMF","MKT_SECTOR":"0","CONTEXT_ID":6423,"DDS_DSO_ID":8334,"SPS_SP_RIC":".[SPSBMFVAE3"}}]


Sent:

  
                
  1.   "ID": 4,
  2.   "Domain": "MarketByOrder",
  3.   "Key": {
  4.     "Service": "ELEKTRON_DD",
  5.     "Name": [
  6.       "2CCMH23",
  7.       "2CCMK23",
  8.       "2CCMN23",
  9.       "2CCMU23",
  10.       "2CCMX23",
  11.       "2CCMF24",
  12.       "2CCMH24",
  13.       "2CCMU24"
  14.     ]
  15.   }
  16. }
#technologyapiwebsocketsmarket-by-order
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
78.1k 246 52 72

@goran.stepanovic

Thanks for reaching out to us.

The stream ID must be unique for each stream or streaming subscription and it will match the request and response.

For example, according to the response below, the stream ID is 4.

 [{
    
  "ID":4,"Type":"Refresh","Key":{"Service":"ELEKTRON_DD","Name":"0#2CCM:"},"State":{
                "Stream":"Open","Data":"Ok"},"Qos":{"Timeliness":"Realtime","Rate":"JitConflated"},"PermData":"AwEBZyPA","SeqNumber":143,"Fields":{"PROD_PERM":6723,"RDNDISPLAY":219,"DSPLY_NAME":"BMF CORN","RDN_EXCHID":"BMF","CURRENCY":"BRL","REF_COUNT":8,"RECORDTYPE":152,"BCAST_REF":"COF","LONGLINK1":"2CCMH23","LONGLINK2":"2CCMK23","LONGLINK3":"2CCMN23","LONGLINK4":"2CCMU23","LONGLINK5":"2CCMX23","LONGLINK6":"2CCMF24","LONGLINK7":"2CCMH24","LONGLINK8":"2CCMU24","LONGLINK9":null,"LONGLINK10":null,"LONGLINK11":null,"LONGLINK12":null,"LONGLINK13":null,"LONGLINK14":null,"LONGPREVLR":null,"LONGNEXTLR":null,"PREF_DISP":1482,"PREF_LINK":null,"DSPLY_NMLL":null,"RDN_EXCHD2":"BMF","MKT_SECTOR":"0","CONTEXT_ID":6423,"DDS_DSO_ID":8334,"SPS_SP_RIC":".[SPSBMFVAE3"}}]

It matches the request message that has the same stream ID #4 which requests 0#2CCM:. The stream state of stream ID #4 is open. Therefore, you can't use this stream ID #4 for another subscription.

For example, to request RICs in this chain, you can use a batch request with stream ID #5.

{
    "ID": 5,
    "Domain": "MarketByOrder",
    "Key": {
        "Service": "ELEKTRON_DD",
        "Name": [
            "2CCMH23",
            "2CCMK23",
            "2CCMN23",
            "2CCMU23",
            "2CCMX23",
            "2CCMF24",
            "2CCMH24",
            "2CCMU24"
        ]
    }
}

Then, this stream ID #5 of the batch request will be closed.

[
    {
        "ID": 5,
        "Type": "Status",
        "Domain": "MarketByOrder",
        "State": {
            "Stream": "Closed",
            "Data": "Ok",
            "Text": "Processed 8 total items from Batch Request.  8 Ok."
        }
    }
]

Each item in the batch request will be assigned a unique ID (#6 - #13).

1676284038730.png

It looks like that these items don't support the Market By Order domain.

To send another request, you can use stream ID #14.

I hope that this information is of help.


1676284038730.png (48.9 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.3k 53 17 14

Hello @goran.stepanovic

The WebSocket JSON message ID (or Stream ID) is like a reference object for each event stream between your application and server. It can be used to match request-response data and a reference for changing that stream (close request, pause, resume).


There are 2 scenarios of the Stream ID. You can find a resource from Make a Batch Request for Multiple Items.


### Single "Item" Request message ###

When you are requesting a single item (Login, Single RIC code, Service, etc), the ID is generated and managed by the application. The server always sends the /response/messages back to the application with the same ID number.

So, you can use ID to match request-response directly in this case.


### Bath (Multiple RICs) Request message ###
However, when the application sends a Batch request (example: ['VOD.L','BT.L', 'BP.L']), The WebSocket server allocates a unique ID to each stream back to the application, and the application needs to use that new ID as a reference instead.

Example:

Request Message: Note the stream ID value of 2 – we will refer back to this shortly.

{
  "ID":2,
  "Key":{
    "Name":["AAPL.O","JPY=" ],
    "Service":"ELEKTRON_DD"
  },
  "View":[ "BID","ASK", "BIDSIZE"]
}

When sending the above JSON message to the server, the first thing we get back is a Status message confirmation of the Batch request:

RECEIVED:
[
  {
    "ID":2,
    "State":{
      "Data":"Ok",
      "Stream":"Closed",
      "Text":"Processed 2 total items from Batch Request.  2 Ok."
    },
    "Type":"Status"
  }
]

Here, the server is advising us that it has processed the Batch request and that it is now closing the request stream with ID of 2 – i.e. the Batch request Stream. This is because the server is going to create individual streams for each of the RICs and allocate a unique ID to each stream.

The next messages we receive are the 3 Initial Refresh Message (or Status Message) for the RICs we requested – note the ID of each one:

{
    "Fields":{
      "ASK":150.76,
      "BID":150.69,
      "BIDSIZE":4
    },
    "ID":3,
    "Key":{
      "Name":"AAPL.O",
      "Service":"ELEKTRON_DD"
    },
    ...
    "State":{
      "Data":"Ok",
      "Stream":"Open"
    },
    "Type":"Refresh"
}
 
{
    "Fields":{
      "ASK":132.59,
      "BID":132.54
    },
    "ID":4,
    "Key":{
      "Name":"JPY=",
      "Service":"ELEKTRON_DD"
    },
    ...
    "State":{
      "Data":"Ok",
      "Stream":"Open"
    },
    "Type":"Refresh"
  }

The WebSocket Server has generated IDs of 3 and 4 to the AAPL.O and JPY= stream respectively. The application must use IDs 3 and 4 as references instead.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.