API Support Forum
OEC API > API Support > Placed Order ID
Author Topic: Placed Order ID
(3 messages, Page 1 of 1)
Moderators: VPfau
RAnde
Posts: 20
Joined: Sep 05, 2017


Posted: Nov 01, 2017 @ 12:02 AM             Msg. 1 of 3
Hello
I have tried to place an order to the developer server "api.gainfutures.com". But when I get the order object returned, the property ID is always -1.
Is that a API bug? Or it is the Gain Capital API design?

Because I need to save the placed order ID into my client order. And I will use that value for getting the order detail. So it doesn't make sense when all orders has ID of -1.

In OEC Trader Developer tool, In the section of "Working Orders", I see that Order has a column called "Order #". It seems like that column is the ID number of Order. If so, how can I get that column from API?
Note that that column is not included in the order returned after I placed an order.
SRuscak
Posts: 7
Joined:


Posted: Nov 01, 2017 @ 08:31 AM             Msg. 2 of 3
Hello RAnde,

I suspect you are looking at the Order returned by OECClient.SendOrder(OrderDraft orderDraft). The OEC API is asynchronous, so the Order has to be sent to the servers and accepted before it can have a valid ID.

Probably you need to subscribe to the OECClient.OnOrderConfirmed event, which will fire once the order is confirmed and will contain the updated Order with a real ID.

We have a basic example on BitBucket that may be helpful to you.
https://bitbucket.org/GainFuturesDev/basicexample/src/6daf45874a3fd8626cdef300840aaa3e8b4b1fd4/MainForm.cs?at=master&fileviewer=file-view-default
SRuscak
RAnde
Posts: 20
Joined: Sep 05, 2017


Posted: Nov 01, 2017 @ 11:58 PM             Msg. 3 of 3
Hi SRuscak

Thank you very much!
As you suspect, I'm getting OrderID from the Order returned by OECClient.SendOrder.
I will try with OECClient.OnOrderConfirmed event.