Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 08:29:35 +0000



Post From: IsWorkingOrderStatus() with server-side bracket OCO

[2015-10-07 02:06:34]
User35525 - Posts: 180
The given examples for walking orders, and continuing if a working order, are this:

if (!IsWorkingOrderStatus(OrderDetails.OrderStatusCode))
continue;

But that doesn't work if it's a server-side bracket OCO parent at CTS, because the order status is always SCT_OSC_FILLED; in case it matters, my parent order type is SCT_ORDERTYPE_MARKET_IF_TOUCHED.

I hacked the following together, however it makes assumptions that aren't always true. Just because a parent has active children, doesn't mean the parent is still active; and just because the parent doesn't have active children, doesn't mean the parent isn't active still. These are bad assumptions in my code. TST told me it's possible for an auto-OCO in T4 (server side bracket in SC) to fill as naked (without a SL), so we cannot always assume the bracket OCO filled perfectly. We need a way to actually determine if a parent order ID is working (via FIX message, passed along to SC API?), so we can monitor the status for problems.


bool IsWorkingBracketOrderIDStatus(int oid, SCStudyGraphRef sc)
{
// Given an order ID, return working order status.
// (This is fine for the working order status of a child, but assumes parents with working children are working, which
// isn't safe, as parents may be non-working but children working, and visa-versa)

// return true if working child order.
// return true if parent with a working child.
// return false if non-working child.
// return false if parent with no working children.
// return false if cannot get order details from passed oid arg.

s_SCTradeOrder OD, CHILD;
if (sc.GetOrderByOrderID(oid, OD) == 1) {
if (OD.ParentInternalOrderID != 0)
return IsWorkingOrderStatus(OD.OrderStatusCode); // return child order status.

// CHECK STATUS OF PARENT (true if any child is still working).
int TargetInternalOrderID= -1;
int StopInternalOrderID= -1;

sc.GetAttachedOrderIDsForParentOrder(oid, TargetInternalOrderID, StopInternalOrderID);
if (TargetInternalOrderID != -1 && sc.GetOrderByOrderID(TargetInternalOrderID, CHILD) == 1) {
if (IsWorkingOrderStatus(CHILD.OrderStatusCode)) return true; // found working child.
}

if (StopInternalOrderID != -1 && sc.GetOrderByOrderID(StopInternalOrderID, CHILD) == 1) {
if (IsWorkingOrderStatus(CHILD.OrderStatusCode)) return true; // found working child.
}

// assume bracket's parent ID non-working just because no working children?
return false;

} else {
return false; // cannot get order details.
}
}

SC needs to have a way to determine if an order ID is working or not, even if it's a server-side order. I'm assuming that we can do that with child orders now, but we need a way to determine if a server-side parent order is working.
Date Time Of Last Edit: 2015-10-07 03:43:40