Support Board
Date/Time: Wed, 10 Sep 2025 00:51:43 +0000
Post From: DTC binary protocol for OCO orders
[2025-07-29 20:32:23] |
User362280 - Posts: 1 |
Hello, I am trying to figure out the paddings (locations and sizes) needed for creating the body of a binary message for OCO order submission via DTC protocol. I was able to figure the right structure for single orders/parent orders but I am stuck to find the right combinason for oco orders (and Yes I have enabled the server side oco and bracket orders and also I send the parent order just before the oco order). The only documentation I found about this is: https://www.sierrachart.com/DTC_Files/DTCProtocol.h and https://www.sierrachart.com/DTC_Files/DTCProtocolVLS.cpp Is it possible to have any kind of working example (to mimic the structure) or more clear information of the required paddings, mapping ? Thanks in advance for any help ! ==================================================== This is the binary structure that I figured out (with all paddings removed): body += fixed_string(symbol, 64) # Symbol (string 64 bytes) body += fixed_string('', 16) # Exchange (string 16 bytes) # --- Order 1: TP --- body += fixed_string(client_order_id_tp, 32) # ClientOrderID_TP (string 32 bytes) body += struct.pack('<i', 2) # OrderType1 (int32 4 bytes) = 2 (LIMIT) body += struct.pack('<i', 1 if buy_sell == 2 else 2) # BuySell1 (int32 4 bytes) body += struct.pack('<d', tp_price) # Price1_1 (double 8 bytes) body += struct.pack('<d', 0.0) # Price2_1 (double 8 bytes) body += struct.pack('<d', quantity) # Quantity_1 (double 8 bytes) # --- Order 2: SL --- body += fixed_string(client_order_id_sl, 32) # ClientOrderID_SL (string 32 bytes) body += struct.pack('<i', 3) # OrderType_2 (int32 4 bytes) = 3 (STOP) body += struct.pack('<i', buy_sell) # BuySell2 (int32 4 bytes) body += struct.pack('<d', sl_price) # Price1_2 (double 8 bytes) body += struct.pack('<d', 0.0) # Price2_2 (double 8 bytes) body += struct.pack('<d', quantity) # Quantity_2 (double 8 bytes) body += struct.pack('<i', 1) # TimeInForce (int32 4 bytes) unset: 0, Day: 1, GTC: 2 body += struct.pack('<q', 0) # GoodTillDateTime (int64 8 bytes) body += fixed_string(TRADE_ACCOUNT, 32) # TradeAccount (string 32 bytes) body += struct.pack('<B', 1) # IsAutomatedOrder (uint8 1 byte) Manual: 0 Auto: 1 body += fixed_string(parent_id, 32) # ParentTriggerClientOrderID body += fixed_string(comment, 48) # FreeFormText body += struct.pack('<i', 0) # OpenOrClose = TRADE_UNSET body += struct.pack('<b', 0) # PartialFillHandling = UNSET body += struct.pack('<B', 0) # UseOffsets = false body += struct.pack('<d', 0.0) # OffsetFromParent1 body += struct.pack('<d', 0.0) # OffsetFromParent2 body += struct.pack('<B', 0) # MaintainSamePricesOnParentFill body += fixed_string('', 16) # Price1_1AsString body += fixed_string('', 16) # Price2_1AsString body += fixed_string('', 16) # Price1_2AsString body += fixed_string('', 16) # Price2_2AsString |