Author |
Topic: "ContractID Invalid" error returned in Order submission (5 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
RAnde Posts: 20 Joined: Sep 05, 2017 |
I got the error as below when calling the SendOrder api to submit an order.
"Invalid OrderDraft: ContractID (277300774, electronic) is invalid" Note that I submit the order with symbol of ESM20. And I get the correct Contract for ESM20 after using the symbol lookup api. Also, I have tried with another symbol (such as GCLN20), but the same error returned. Is there anyone known this error? And how should I do to solve it? Edited by RAnde on Jun 02, 2020 04:13 AM |
||||
ETrifonov Posts: 63 Joined: |
Hello RAnde,
Unfortunately it is not clear how exactly you are creating order. If you are getting contract via api and then use it to create new order draft, you shouldn't have such issues. Can you please provide code and GF API version. Our sample in API documentation: https://gainfutures.com/GFAPI/?topic=html/b7c07332-6ce9-4101-bec2-79610ad6ee7d.htm Thank you. Evgeny
|
||||
RAnde Posts: 20 Joined: Sep 05, 2017 |
Hi Evgeny,
I'm getting contract by using the api of IGFCLient.Contracts.Lookup.ByCriteria. And then I use the ContractID of that contract to create the order draft for the order placing. The process is same as your example. Please look at the code details as below The code of symbol lookup
Create OrderDraft
Place order
And I'm using GF API version 4.0.3.33 Thanks Evgeny for helping. |
||||
ETrifonov Posts: 63 Joined: |
Thank you for details.
Can you please also provide account you used to place orders. Also, I see that to place order you first deserialize it. Question is - does _clientRunner.Client is the same, used for contract lookup and was it connected during whole session? To send order, API should know about contract. So, in case you lookup contract. build draft, serialize order draft, reconnect API, deserialize order and trying to send it - you will get that error. After reconnect you should lookup contract again, to make sure API knows about it. Thank you. Evgeny
|
||||
RAnde Posts: 20 Joined: Sep 05, 2017 |
Hi Evgeny,
You are correct. I'm using two different IGFClient objects for the processes of symbol lookup and order draft sending. So the client in the order draft sending did not know the Contact that is from the symbol lookup. I have moved the symbol lookup inside the order draft sending process so that they can use the same client. And the problem disappears. Thank you very much for helping. Edited by RAnde on Jun 04, 2020 03:36 AM |
||||