How to get Orders in OnMessageReceived

Created at 21 Feb 2024, 06:21
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
IG

iggys77

Joined 20.02.2024

How to get Orders in OnMessageReceived
21 Feb 2024, 06:21


How do I get the orders from the message in c#? The PayLoadType is 2176, so PROTO_OA_ORDER_LIST_RES (the response),but how do I convert the message to it? Tried several ways but with no luck and cannot find any examples online… 

 

private void OnMessageReceived(IMessage message)
{
   _logger.Log(LogLevel.Information, "The app got a MESSAGE in OnMessageReceived");
   _logger.Log(LogLevel.Information, "The app got message = " + message);

   switch (message.GetPayloadType().ToString())
   {
       case "2176":


@iggys77
Replies

PanagiotisCharalampous
21 Feb 2024, 07:11

Hi there,

You can check our Open API example here

https://github.com/spotware/OpenAPI.Net

Best regards,

Panagiotis


@PanagiotisCharalampous

iggys77
21 Feb 2024, 07:51 ( Updated at: 21 Feb 2024, 09:45 )

Hi!

Thanks, yes I did, I used it a lot to get to this point, but I can't find any example where the private void OnMessageReceived(IMessage message) is used to read the actual message, it only writes it out.

I couldn't find any example at all where the OnMessageReceived did anytheing else that just writing out, could you post here how I should get/create the ROTO_OA_ORDER_LIST_RES from the message? In this case it's the orders list but it could be any of the other objects returned by the API… 

Or please point me to the file where there is such an example, I did check them all I think.

Thx!


@iggys77

PanagiotisCharalampous
21 Feb 2024, 09:56

RE: How to get Orders in OnMessageReceived

iggys77 said: 

Hi!

Thanks, yes I did, I used it a lot to get to this point, but I can't find any example where the private void OnMessageReceived(IMessage message) is used to read the actual message, it only writes it out.

I couldn't find any example at all where the OnMessageReceived did anytheing else that just writing out, could you post here how I should get/create the ROTO_OA_ORDER_LIST_RES from the message? In this case it's the orders list but it could be any of the other objects returned by the API… 

Or please point me to the file where there is such an example, I did check them all I think.

Thx!

Hi there,

It is a lot of work to develop such an example so I cannot provide one at the moment. You can leave a comment in the GitHub repository so that it can be considered for future updates. In the meanwhile, have a look at the OpenApiMessageToString() method in WinForms.Demo.OpenApiMessagesPresentation class, to see some examples how other messages are read.

Best regards,

Panagiotis


@PanagiotisCharalampous