API Support Forum
OEC API > API Support > SendLinkedOrders causes MKT order to hang in development environment
Author Topic: SendLinkedOrders causes MKT order to hang in development environment
(3 messages, Page 1 of 1)
Moderators: VPfau
CKeslin1490
Posts: 4
Joined: Oct 31, 2018


Posted: Jan 09, 2020 @ 10:56 AM             Msg. 1 of 3
Hello,

I'm attempting to send a MKT buy order that has a linked Stop order with based on the Fill price of the MKT order. If I do not include a price on the Stop order it has an invalid part and will not submit. Providing a price shouldn't be necessary because I want to go off the fill price of the MKT (which does not have a price, but works as expected)

If I send the MKT order alone, it is sent and filled as expected. If I send the MKT order as a SendLinkedOrders with the stop as shown in the code below, the MKT order hangs in the "sent" state and the stop order is "held". They never leave this state and I need support to clear the working orders for me because canceling them fails with "another cancel attempt is running"

Sample code that will reproduce the issue is below. Thanks in advance for your help.

var mainOrder = gainClient.CreateDraft();

mainOrder.Account = gainAccount;
mainOrder.Contract = gainContract;
mainOrder.Comments = "Main Order";
mainOrder.Quantity = 1;
mainOrder.Side = OrderSide.Buy;
mainOrder.Start = OEC.API.Version.MinimumStart;
mainOrder.End = OEC.API.Version.MaximumEnd;
mainOrder.Type = OrderType.Market;

if (OrderParts.None != mainOrder.GetInvalidParts())
return;

var draftStopOrder = gainClient.CreateDraft();

draftStopOrder.Account = gainAccount;
draftStopOrder.Contract = gainContract;
draftStopOrder.Comments = "Stop Order activated on MKT fill";
draftStopOrder.Quantity = 1;
draftStopOrder.Side = OrderSide.Sell;
draftStopOrder.Start = OEC.API.Version.MinimumStart;
draftStopOrder.End = OEC.API.Version.MaximumEnd;
draftStopOrder.Type = OrderType.Stop;
draftStopOrder.Price = 3598; //Shouldn't need to set this
draftStopOrder.DeltaTicks = -10;

var draftStopOrderInvalidParts = draftStopOrder.GetInvalidParts();

if (OrderParts.None != draftStopOrderInvalidParts)
return;

gainClient.SendLinkedOrders(mainOrder, OSOGroupingMethod.ByPrice, draftStopOrder);
JSmith5611
Posts: 187
Joined:


Posted: Jan 10, 2020 @ 10:15 AM             Msg. 2 of 3
We have determined the cause of this issue and a fix will be pushed this weekend.
Jason Smith
CKeslin1490
Posts: 4
Joined: Oct 31, 2018


Posted: Jan 10, 2020 @ 01:46 PM             Msg. 3 of 3
Thank you!