Can I get a C# example to do request/response over TREP using the EEP service.

I was successfully able to integrate the Websocket API in my project but there are some use cases that require some more thought. I would like to know the best way to retrieve data using Request/Response over TREP. I am currently using C# to make this request. Can someone point me to such an example?

Best Answer

  • Gurpreet
    Answer ✓

    Hello @ahmad.siddiqi, You can download the samples package from Elektron SDK downloads page. In the WebSocket API Sample Applications download, there are examples of MarketPrice, MarketByPrice and MarketByOrder etc in C#.

    Please note that websockets have to be enabled in your TREP infrastructure (on ADS).

Answers

  • This is fine but isn't there a way to do simple request/response to get data or is the only way to get data is by doing a WebSocket call? Is there another api I can hit over TREP to request some data instead of writing a complicated WebSocket wrapper?

  • There is an Elektron SDK available in both C++ and Java only. The SDK will allow you to use API to get the data. You can follow step by step tutorials for these in the developers portal. I may apprise you, that while SDK is better suited for low latency, high volume data, it is also complex to use compared to Websocket API - which is based on simple JSON format.

  • Thanks for the quick response. Do you have a C# example of EMA and ETA? How do people typically use C# for communicating through these channels?

  • Sorry, only C++ and Java are supported API for EMA or ETA.

  • Ok thats fine. Using websockets if I request data in a batch looks to me like there is no guarantee that the data will come back in one response. Is there a way to determine when the client receives all the data requested via the batch?

  • Hi @ahmad.siddiqi

    As well as my colleagues explanation of how each item in a Batch has its own stream ID, there is alternative simpler technique you could use to confirm if you have received a response for all items.

    If you look at my Python Websocket example on Github, you will note that when the number of RefreshMsg + Closed status responses = the number of items in my batch, then I mark this as all items responded to. If you are using Streaming requests (rather than Snapshot), then you can expect to continue receiving UpdateMsgs in line with market activity for your subscribed instruments.

    # Cleanup and exit - if autoExit and we have received response to all requests
    if (autoExit and (reqCnt==imgCnt+closedCnt)):
        cleanup(ws)

    So, for all valid subscription requests you should receive a RefreshMsg. For any invalid requests e.g. invalid RIC or items you are not permissioned for, you would receive a StatusMsg with a Suspect State (as demonstrated in my code).