spotware / openapi-proto-messages

Open API Proto Messages
https://openapi.ctrader.com
MIT License
21 stars 9 forks source link

Open API Suggestions #3

Closed Vasile-Peste closed 2 years ago

Vasile-Peste commented 2 years ago

Hello there, following my tests on Open API I would suggest:

Some ambigous circumstances:

Just some suggestions. I understand that your API already provides the fundamental functionalities to operate in markets. I'm creating a framework for operating with NodeJS which uses Open API under the hood: I'm glad to contribute if you need me.

amusleh-spotware-com commented 2 years ago

Hi, Here is our response for each of you abovementioned points:

Vasile-Peste commented 2 years ago

Alright, regarding the last point. I would like to make an example.

I send two asynchronous order requests for EURUSD and XAUUSD symbols. I get two events,

First one

{
  payloadType: 'PROTO_OA_ORDER_ERROR_EVENT',
  ctidTraderAccountId: 'xxx',
  errorCode: 'INVALID_VOLUME'  orderId: null,
  positionId: null,
  description: 'Trading is not available: Market is closed.'
}

Second one

{
  payloadType: 'PROTO_OA_ORDER_ERROR_EVENT',
  ctidTraderAccountId: 'xxx',
  errorCode: 'TIMEOUT_ERROR'  orderId: null,
  positionId: null,
  description: 'Trading is not available: Market is closed.'
}

How to associate each error response to the respective order request? How do I know if timeout is for EURUSD request or XAUUSD request?

raul-gherman commented 2 years ago

hey @Vasile-Peste you can use clientMsgId (at ProtoMessage level) -- if you set its value at request level, you will receive the same value at reply level, thus knowing exactly which reply was sent for which request

Vasile-Peste commented 2 years ago

hey @Vasile-Peste you can use clientMsgId (at ProtoMessage level) -- if you set its value at request level, you will receive the same value at reply level, thus knowing exactly which reply was sent for which request

The example I made is not about request reply: it's about events, more precisely ProtoOAExecutionEvent, and they do not contain the clientMsgId of your request. I have just printed the server event after performing the order request, it's clear that the clientMsgId is not defined in the event.

raul-gherman commented 2 years ago

than the proper request, I guess, is to include clientMsgId (on backend side) in ProtoOAExecutionEvent that is dispatched (still, not sure how easy or hard it is to keep track -- once again, on backend side)

amusleh-spotware-com commented 2 years ago

Alright, regarding the last point. I would like to make an example.

I send two asynchronous order requests for EURUSD and XAUUSD symbols. I get two events,

First one

{
  payloadType: 'PROTO_OA_ORDER_ERROR_EVENT',
  ctidTraderAccountId: 'xxx',
  errorCode: 'INVALID_VOLUME'  orderId: null,
  positionId: null,
  description: 'Trading is not available: Market is closed.'
}

Second one

{
  payloadType: 'PROTO_OA_ORDER_ERROR_EVENT',
  ctidTraderAccountId: 'xxx',
  errorCode: 'TIMEOUT_ERROR'  orderId: null,
  positionId: null,
  description: 'Trading is not available: Market is closed.'
}

How to associate each error response to the respective order request? How do I know if timeout is for EURUSD request or XAUUSD request?

Hi,

The PROTO_OA_ORDER_ERROR_EVENT returns the client message ID, here is an example:

payloadType: 2132 payload: "\022\022TRADING_BAD_VOLUME(\362\366\224\010::Order volume 1.00 is smaller than group minVolume=1000.00." clientMsgId: "dsfdsf"

I send a new order request with invalid volume amount, and I received back the above response which has my client message ID.

Vasile-Peste commented 2 years ago

Clear! You are right, my bad cause I parse only the payload of incoming messages. Thank you for your patience, I'm looking forward to see your updates.