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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 1 2

Batch request for CSharp RRTO

I used this sample code websocket-api/Applications/Examples/RDP/CSharp/MarketPriceRdpGwAuthenticationExample/ for requesting single stock market price data, it works perfectly. I reviewed the output data with our business product yesterday, they said we need to request not just one stock, it could be 500+ stocks market price. So, that program doesn't work for batch requests.

my questions here:

1. Could you suggest a .net batch version of this program websocket-api/Applications/Examples/RDP/CSharp/MarketPriceRdpGwAuthenticationExample/ ?

2. Is there a limit per batch? How could we implement 500+ stocks requesting data?

#technologyc#refinitiv-realtime-optimised
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.

Upvote
Accepted
18.2k 84 39 63

Hi @Saifullah.Hassan

There is no specific equivalent .Net batch request example. However, the capability is not much more than creating a list of items within the request. For example:

{
  "ID": 2,
  "Streaming": true,
  "Key": {
    "Name": ["CAD=","EUR="]
  },
  "View": ["BID","ASK","DSPLY_NAME"]
}

There is a limit on the size of the batch. Specifically, the WebSocket streaming services limit the size of a request based on a byte limit returned from the login. For example, within the login response, you will see the limit:

{
  "ID": 1,
  "Type": "Refresh",
  "Domain": "Login",
  "Key": {
    "Name": "...",
    ...
  },
  ..
  "Elements": {
    "PingTimeout": 30,
    "MaxMsgSize": 61516
  }
}

The "MaxMsgSize" defines the size of the total cargo (JSON message) sent. You will need to perform some general calculation to determine the size of the message (in bytes) based on the list of items you plan to send in your batch.

Alternatively, you can use the Refinitiv Data Library for .Net. This library is built on top of the WebSocket service and provides a lot of value including session and token management, a simple Pricing interface, manages maximum message limits on behalf of the user. I would suggest you refer to the Pricing examples defined within GitHub.

Here is a simple batch request using the library:

ahs.png


ahs.png (21.2 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
1 0 0 1

Hi Nick,

Thank you for your comment! As you said I created a list of item in the example program I used websocket-pi/Applications/Examples/RDP/CSharp/MarketPriceRdpGwAuthenticationExample.

1670949725036.png

here is the output from this program, it doesn't output data anymore, saying access denied. could you help how to make it work for the 3 items sent? Thank you!

{

"ID": 2,

"Key": {

"Name": [

"TRI.N",

"IBM.N",

"T.N"

],

"Service": "ELEKTRON_DD"

}

}


RECEIVED on Session1:

[

{

"ID": 2,

"Type": "Status",

"State": {

"Stream": "Closed",

"Data": "Ok",

"Text": "Processed 3 total items from Batch Request. 3 Ok."

}

}

]


RECEIVED on Session1:

[

{

"ID": 4,

"Type": "Status",

"Key": {

"Service": "ELEKTRON_DD",

"Name": "IBM.N"

},

"State": {

"Stream": "Closed",

"Data": "Suspect",

"Code": "NotEntitled",

"Text": "Access Denied: User req to PE(62)"

}

}

]


RECEIVED on Session1:

[

{

"ID": 5,

"Type": "Status",

"Key": {

"Service": "ELEKTRON_DD",

"Name": "T.N"

},

"State": {

"Stream": "Closed",

"Data": "Suspect",

"Code": "NotEntitled",

"Text": "Access Denied: User req to PE(62)"

}

},

{

"ID": 3,

"Type": "Status",

"Key": {

"Service": "ELEKTRON_DD",

"Name": "TRI.N"

},

"State": {

"Stream": "Closed",

"Data": "Suspect",

"Code": "NotEntitled",

"Text": "Access Denied: User req to PE(6562)"

}

}

]



1670949725036.png (28.5 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
18.2k 84 39 63

Hi @huanjie

The above output indicates you do not have permissions to request for the instruments: "TRI.N", "T.N", "IBM.N". You may need to confirm with your account manager what data you have been permissioned to access. You may want to try delayed RICs - for example: "/TRI.N", "/T.N", "/IBM.N".

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
1 0 0 1

Hi Nick, you are right, I put "/" in front of the names like "/TRI.N", "/T.N", "/IBM.N", it worked.

Thank you so much for your help! :-)

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
25.7k 58 17 14

Hello @huanjie

Actually, the Batch example is available in MarketPriceBatchViewExample.cs RTDS example (websocket-api/Applications/Examples/CSharp/). The examples in this non-RDP folder are for the deployed RTDS connection. However, the logic of requesting a batch is the same as my colleague suggested.

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
1 0 0 1

Hi @wasin.w Thank you for your help! I tried the code your suggested early. it didn't work at all. it requests a lot of parameters, when I execute it, it just throwed exceptions which doesn't give much info. So I thought it might be an outdated program,won't work. So I started to use websocket-api/Applications/Examples/RDP/CSharp/MarketPriceRdpGwAuthenticationExample/ to send batch requests, it works. but I am still testing it with a lot of items.

I found one issue during my testing, I sent 60 instrument codes as a batch, then I got 130-140 response messages back, and then the program seems stuck and no error messages, after a while, I saw it start to do below again and again very slowly, and there is no error, seems still going, but just re authentication again and again and no response message coming back anymore. I thought once I sent requests out, the stream will be endless without stopping, what cause it stuck there?

here is the output, could you please help?

Sending authentication request (isRefresh True) to https://api.refinitiv.com:443/auth/oauth2/v1/token

RECEIVED:

{

"access_token": "xxxx"

"refresh_token": "xxxx",

"expires_in": "600",

"scope": "trapi.streaming.pricing.read",

"token_type": "Bearer"

}


SENT on Session1:

{

"ID": 1,

"Domain": "Login",

"Key": {

"NameType": "AuthnToken",

"Elements": {

"ApplicationId": "256",

"Position": "192.168.2.44",

"AuthenticationToken": "xxxxx"

}

},

"Refresh": false

}

@nick.zincone could you please help?


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.

Hi @huanjie

I would first try to send "non-streaming" requests, i.e. "Streaming": false. For example:

{
  "ID": 2,
  "Streaming": false,
  "Key": {
    "Name": "AAPL.O"
  },
  "View": [
    "BID",
    "ASK",
    "CF_LAST"
  ]
}

This will confirm whether you received 60 responses (Refresh or Status). The above messages are to refresh the access token required by the streaming service - which is why you receive them periodically. As for not receiving anything else, this may have to do with when you are sending the requests - are they out of market hours. I would also suggest you reduce your batch size to just a few - to test if the behavior is as expected.

Upvotes
1 0 0 1

@nick Thank you for your help!

I figured it might not be an issue, because after we get those refresh and update complete, there could be no more messages to send. So I only see the token refreshed and re-authenticate, once next day market opened, we should continually receive more response messages.

So, I will deploy it and have it run for few days, if I can see data on each day, it should be good.

Thank you again!

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.