Login Page - Create Account

Support Board


Date/Time: Sun, 28 Apr 2024 20:40:14 +0000



Post From: DTC Bracket Order ignoring parent and executing

[2018-04-09 19:21:41]
User942837 - Posts: 108
Hi, I am submitting 2 messages via json to DTC server. I am first sending SUBMIT_NEW_SINGLE_ORDER as a parent order, then SUBMIT_NEW_OCO_ORDER with a stop and a target. In the SUBMIT_NEW_SINGLE_ORDER I am setting ParentTriggerClientOrderId that I used in the SUBMIT_NEW_SINGLE_ORDER.

E.g. My entry price is
double entry = 2637;
double target = 2640.25;
double stop = 2635.25;

As soon as I send SUBMIT_NEW_OCO_ORDER, and market is trading above my target (2640.25), the 2640.25 sell Lmt OCO gets executed at market. With the example I have provided below what I am expecting is to have a buy LMT order (parent) waiting to be filled and the 2 OCOs will only get executed after the parent order is filled. Could you kindly let me know what am I doing wrong please?

Thank you

string clientOrderId = "43ddfs51aa";
string clientOrderId1 = "454334aa";
string clientOrderId2 = "454334bb";

double entry = 2637;
double target = 2640.25;
double stop = 2635.25;

byte[] SUBMIT_NEW_SINGLE_ORDER = JsonMessageToByteArray("{\"Type\":208,\"Symbol\":\"ESM8\",\"ClientOrderID\":\"" + clientOrderId + "\",\"OrderType\":2,\"BuySell\":1,\"Price1\":" + entry + ",\"TimeInForce\":1,\"Quantity\":1,\"TradeAccount\":\"DEMOAC\",\"IsAutomatedOrder\":0,\"IsParentOrder\":1,\"OpenOrClose\":1}");
SendAndReceive(dtcSocket, SUBMIT_NEW_SINGLE_ORDER);


string SUBMIT_NEW_OCO_ORDER = "{\"Type\":201,\"Symbol\":\"ESM8\",\"ClientOrderID_1\":\"" + clientOrderId1 + "\",\"OrderType_1\":2,\"BuySell_1\":3,\"Price1_1\":" + stop + ",\"Quantity_1\":1,\"ClientOrderID_2\":\"" + clientOrderId2 + "\",\"OrderType_2\":2,\"BuySell_2\":2,\"Price1_2\":" + target + ",\"Quantity_2\":1,\"TimeInForce\":1,\"IsAutomatedOrder\":0,\"TradeAccount\":\"DEMO0AC\",\"ParentTriggerClientOrderId\":\"" + clientOrderId + "\",\"OpenOrClose\":2,\"PartialFillHandling\":1}";
SendAndReceive(dtcSocket, JsonMessageToByteArray(SUBMIT_NEW_OCO_ORDER));