¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Bracket order - "good after time" fires immediately


 

Hi,

Bracket order - "good after time" fires immediately
Python - win 10 , API , FB

I have a sturdy working 'classic' bracket order, running live for a few months
parent limit order,
child limit target order,
child stop stop-loss order,

I wanted to add a 'good after time' - to close position
child market 'good after time' order.

The surprising result is an immediate trigger of the "child market 'good after time' order",
straight after the parent is executed.
so basically I end up closing my position within a few milliseconds !!!!!!

Naturally I assumed I am not giving the correct date format
# from API: Format: yyyymmdd hh:mm:ss {optionalTimezone}. 20210115 07:22:56
tried various combination, none work
changed year to 2022, yet it still fires immediately
GAT.GoodAfterTime = "20220612 15:55:00"

# GAT.GoodAfterTime = ""
# tried time zone in different manners

actual chain of events:
parent executed
child limit target order, canceled
child stop stop-loss order ,canceled
child market 'good after time executed

see after snippet -> run time messages and debug log file

NOTE: I run in a GMT -2 time zone, however my workstation and all code is set to 'US/Eastern'


# ========================== begin snippet (omitted irrelevant code) ===================================================

def doBracketOrder(self, action: str):

print("doBracketOrder action=", action)

# ======= parent =====
parent = Order()
parent.orderId = self.nextOrderId
self.parentID = self.nextOrderId
parent.action = action
parent.orderType = 'LMT'
parent.totalQuantity = quantity
parent.transmit = False

# ======= takeProfit =====
takeProfit = Order()
takeProfit.orderId = self.nextOrderId + 1
takeProfit.action = m_action
takeProfit.orderType = 'LMT'
takeProfit.totalQuantity = quantity
takeProfit.lmtPrice = takeProfitLimitPrice
takeProfit.parentId = self.nextOrderId
takeProfit.transmit = False

# ======= stop loss =====
stopLoss = Order()
stopLoss.orderId = self.nextOrderId + 2
stopLoss.action = m_action
stopLoss.orderType = "TRAIL"
stopLoss.totalQuantity = quantity
stopLoss.trailingPercent = 1
stopLoss.parentId = self.nextOrderId
stopLoss.transmit = False

# ======= GoodAfterTime to sell MKT at specified time =====
# Format: yyyymmdd hh:mm:ss {optionalTimezone}. 20210115 07:22:56
nowT = datetime.datetime.now(pytz.timezone('US/Eastern'))
nowT += datetime.timedelta(minutes=3)
strFire = nowT.strftime('%Y%m%d %H:%M:%S')

GAT = Order()
GAT.orderId = self.nextOrderId + 3
GAT.action = m_action
GAT.orderType = 'MKT'
GAT.totalQuantity = quantity

GAT.GoodAfterTime = strFire
# GAT.GoodAfterTime = "" tried various combination, none work
# GAT.GoodAfterTime = "20220612 15:55:00" changed year to 2022, yet it still fires immediately

GAT.parentId = self.nextOrderId
GAT.transmit = True

# ======================== fire the orders ========================
self.placeOrder(self.nextOrderId, self.contract, parent)
self.placeOrder(self.nextOrderId + 1, self.contract, takeProfit)
self.placeOrder(self.nextOrderId + 2, self.contract, stopLoss)
self.placeOrder(self.nextOrderId + 3, self.contract, GAT)

self.nextOrderId += 3

# ==================== end snippet ==========================


# ==================== messages ==========================
"""
280 = parent
281 = child limit target order,
282 = child stop stop-loss order ,
283 = child market 'good after time

2021-01-15 10:31:32.146463-05:00 Order Executed: -1 250.64 FB STK USD 0000e0d5.603e096f.01.01 280 42.0 2

2021-01-15 10:31:32.179375-05:00 commissionReport= ExecId: 0000e0d5.603e096f.01.01, Commission: 0.566899, Currency: USD, RealizedPnL: , Yield: , YieldRedemptionDate: 0

2021-01-15 10:31:32.210292-05:00 reqId= 282 errorCode= 202 errorString= Order Canceled - reason:
self.legCancel = True

2021-01-15 10:31:32.266141-05:00 reqId= 282 errorCode= 202 errorString= Order Canceled - reason:
self.legCancel = False

2021-01-15 10:31:32.273125-05:00 Order Executed: -1 250.68 FB STK USD 0000e0d5.603e0970.01.01 283 42.0 2

2021-01-15 10:31:32.285091-05:00 commissionReport= ExecId: 0000e0d5.603e0970.01.01, Commission: 0.329257, Currency: USD, RealizedPnL: -2.576157, Yield: , YieldRedemptionD
ate: 0
2021-01-15 10:31:32.299053-05:00 reqId= 281 errorCode= 202 errorString= Order Canceled - reason:
self.legCancel = True
"""
# ==================== debug log extract ==========================
"""
280 = parent
281 = child limit target order,
282 = child stop stop-loss order ,
283 = child market 'good after time

10:31:32:179 -> ---2-6-1-8-81931----1-6-1-6-252.38-0-0----1-6-1-7-247.16-0-0----1-6-1-9-245.64-0-0-
10:31:32:179 -> ---1-6-1-14-248.54-0-0-
10:31:32:180 -> ---
2-6-1-0-1----
2-6-1-3-1---- 46-6-1-32-Q---- 46-6-1-33-Q-
10:31:32:601 -> --->50-3-2109-1610724685-250.685-250.77-250.66-250.73--1--1.00--1-
10:31:32:609 <- 3-280-0-FB-STK--0.0---SMART--USD-----SELL-42-LMT-250.56------0--0-0-0-0-0-0-0-0--0--------0---1-0---0---1-1--0------0-----0-----------0---0-0---0--0-0-0-0--1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-0----1.7976931348623157e+308-----0-0-0--
10:31:32:613 <- 3-281-0-FB-STK--0.0---SMART--USD-----BUY-42-LMT-250.46------0--0-280-0-0-0-0-0-0--0--------0---1-0---0---1-1--0------0-----0-----------0---0-0---0--0-0-0-0--1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-0----1.7976931348623157e+308-----0-0-0--
10:31:32:615 <- 3-282-0-FB-STK--0.0---SMART--USD-----BUY-42-TRAIL-------0--0-280-0-0-0-0-0-0--0--------0---1-0---0---1-1--0------0-----0--250.99-1--------0---0-0---0--0-0-0-0--1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-0----1.7976931348623157e+308-----0-0-0--
10:31:32:617 <- 3-283-0-FB-STK--0.0---SMART--USD-----BUY-42-MKT-------0--1-280-0-0-0-0-0-0--0--------0---1-0---0---1-1--0------0-----0-----------0---0-0---0--0-0-0-0--1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-0----1.7976931348623157e+308-----0-0-0--
10:31:33:086 -> ---
2-6-1-0-2----
2-6-1-3-2----
46-6-1-32-QZ-
10:31:33:122 -> --g5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-1-1--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----73-281-PreSubmitted-0-42-0-164734757-280-0-6579-child-0-
10:31:33:125 -> --f5-282-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-TRAIL-0.0--DAY-164734756-DU2354601--0--6579-164734758-0-0-0--164734758.0/DU2354601/100----------0---1-0-------0-0-0--3-1-1--280-0--0-None--0----?-0-0--0-0--1.0----0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-250.99-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----?3-282-PreSubmitted-0-42-0-164734758-280-0-6579-child,trigger-0-
10:31:33:127 -> --d5-283-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-MKT-0.0-0.0-DAY-164734756-DU2354601--0--6579-164734759-0-0-0--164734759.0/DU2354601/100----------0---1-0-------0-0-0--3-1-1--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.68-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----73-283-PreSubmitted-0-42-0-164734759-280-0-6579-child-0-
10:31:33:145 -> --]5-280-107113386-FB-STK--0-?--SMART-USD-FB-NMS-SELL-42-LMT-250.56-0.0-DAY--DU2354601--0--6579-164734756-0-0-0--164734756.0/DU2354601/100----------0---1-0-------0-0-0--3-1-1--0-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-249.56-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----03-280-PreSubmitted-0-42-0-164734756-0-0-6579--0-
10:31:33:149 -> --g5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----73-281-PreSubmitted-0-42-0-164734757-280-0-6579-child-0-
10:31:33:153 -> --f5-282-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-TRAIL-0.0--DAY-164734756-DU2354601--0--6579-164734758-0-0-0--164734758.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0--1.0----0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-250.99-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----?3-282-PreSubmitted-0-42-0-164734758-280-0-6579-child,trigger-0-
10:31:33:157 -> --f5-282-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-TRAIL-0.0--DAY-164734756-DU2354601--0--6579-164734758-0-0-0--164734758.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0--1.0----0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-250.99-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----?3-282-PreSubmitted-0-42-0-164734758-280-0-6579-child,trigger-0-
10:31:33:161 -> --f5-282-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-TRAIL-0.0--DAY-164734756-DU2354601--0--6579-164734758-0-0-0--164734758.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0--1.0----0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-250.99-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----?3-282-PreSubmitted-0-42-0-164734758-280-0-6579-child,trigger-0-
10:31:33:164 -> --d5-283-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-MKT-0.0-0.0-DAY-164734756-DU2354601--0--6579-164734759-0-0-0--164734759.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.68-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----73-283-PreSubmitted-0-42-0-164734759-280-0-6579-child-0-
10:31:33:173 -> ---?11--1-280-107113386-FB-STK--0.0---IBKRATS-USD-FB-NMS-0000e0d5.603e096f.01.01-20210115 10:31:33-DU2354601-IBKRATS-SLD-42-250.64-164734756-6579-0-42-250.64-----2-
10:31:33:175 -> --W5-280-107113386-FB-STK--0-?--SMART-USD-FB-NMS-SELL-42-LMT-250.56-0.0-DAY--DU2354601--0--6579-164734756-0-0-0--164734756.0/DU2354601/100----------0---1-0-------0-0-0--3-1-1--0-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-Filled-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-249.56-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----43-280-Filled-42-0-250.64-164734756-0-250.64-6579--0-
10:31:33:180 -> --g5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----23-281-PreSubmitted-0-42-0-164734757-280-0-6579--0-
10:31:33:185 -> --d5-283-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-MKT-0.0-0.0-DAY-164734756-DU2354601--0--6579-164734759-0-0-0--164734759.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.68-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----23-283-PreSubmitted-0-42-0-164734759-280-0-6579--0-
10:31:33:188 -> --b5-280-107113386-FB-STK--0-?--SMART-USD-FB-NMS-SELL-42-LMT-250.56-0.0-DAY--DU2354601--0--6579-164734756-0-0-0--164734756.0/DU2354601/100----------0---1-0-------0-0-0--3-1-1--0-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-Filled-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0.566899---USD--0-0-0-None-1.7976931348623157E308-249.56-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----43-280-Filled-42-0-250.64-164734756-0-250.64-6579--0-
10:31:33:188 -> ---Y59-1-0000e0d5.603e096f.01.01-0.566899-USD-1.7976931348623157E308-1.7976931348623157E308--
10:31:33:196 -> --d5-283-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-MKT-0.0-0.0-DAY-164734756-DU2354601--0--6579-164734759-0-0-0--164734759.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PreSubmitted-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.68-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----23-283-PreSubmitted-0-42-0-164734759-280-0-6579--0-
10:31:33:199 -> --g5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-0-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PendingCancel-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----23-281-PendingCancel-0-0-0-164734757-280-0-6579--0-
10:31:33:203 -> --g5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-0-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-PendingCancel-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----23-281-PendingCancel-0-0-0-164734757-280-0-6579--0-
10:31:33:212 -> ---/3-282-Cancelled-0-42-0-164734758-280-0-6579--0----%4-2-282-202-Order Canceled - reason:-
10:31:33:300 -> ---/3-282-Cancelled-0-42-0-164734758-280-0-6579--0----%4-2-282-202-Order Canceled - reason:-
10:31:33:307 -> ---?11--1-283-107113386-FB-STK--0.0---IBKRATS-USD-FB-NMS-0000e0d5.603e0970.01.01-20210115 10:31:33-DU2354601-IBKRATS-BOT-42-250.68-164734759-6579-0-42-250.68-----2-
10:31:33:308 -> --^5-283-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-MKT-0.0-0.0-DAY-164734756-DU2354601--0--6579-164734759-0-0-0--164734759.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-Filled-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.68-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----63-283-Filled-42-0-250.68-164734759-280-250.68-6579--0-
10:31:33:311 -> --i5-283-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-42-MKT-0.0-0.0-DAY-164734756-DU2354601--0--6579-164734759-0-0-0--164734759.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-Filled-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0.329257---USD--0-0-0-None-1.7976931348623157E308-251.68-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-0----63-283-Filled-42-0-250.68-164734759-280-250.68-6579--0-
10:31:33:311 -> ---L59-1-0000e0d5.603e0970.01.01-0.329257-USD--2.576157-1.7976931348623157E308--
10:31:33:328 -> --`5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-0-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-Filled-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----+3-281-Filled-0-0-0-164734757-280-0-6579--0-
10:31:33:330 -> --`5-281-107113386-FB-STK--0-?--SMART-USD-FB-NMS-BUY-0-LMT-250.46-0.0-DAY-164734756-DU2354601--0--6579-164734757-0-0-0--164734757.0/DU2354601/100----------0---1-0-------0-0-0--3-0-0--280-0--0-None--0----?-0-0--0-0------0-0-0-----0--IB-0-0--0-0-Filled-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308------0-0-0-None-1.7976931348623157E308-251.46-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-1.7976931348623157E308-0----0-1-0-0-1----+3-281-Filled-0-0-0-164734757-280-0-6579--0----%4-2-281-202-Order Canceled - reason:-
10:31:33:590 -> ---2-6-1-8-81932-
10:31:33:591 -> ---46-6-1-45-1610724694-
10:31:33:592 -> ---1-6-1-4-250.68-1-0----
2-6-1-5-1-
10:31:33:592 -> ---1-6-1-1-250.70-1-1----1-6-1-2-250.80-4-1----
2-6-1-0-1----
2-6-1-3-4---- 46-6-1-32-Z---- 46-6-1-33-K-
10:31:33:842 -> ---1-6-1-1-250.73-1-1----1-6-1-2-250.82-3-1----
2-6-1-3-3---- 46-6-1-32-J----46-6-1-33-KQZ-
10:31:34:092 -> ---2-6-1-8-82123-
10:31:34:093 -> --- 46-6-1-84-J-
10:31:34:093 -> ---1-6-1-4-250.82-1-0-
10:31:34:094 -> ---1-6-1-2-250.84-7-1----
2-6-1-0-5----
2-6-1-3-7----46-6-1-32-KPQZ----
46-6-1-33-QZ-
10:31:34:341 -> ---1-6-1-1-250.79-1-1----
2-6-1-0-1----
2-6-1-3-6---- 46-6-1-32-Q---- 46-6-1-33-Z-
10:31:34:593 -> ---2-6-1-8-82124-
"""


 

If you look at your debug log extract, for your order id 283 (the GAT order, you'd see the following:

10:31:32:617 <- 3-283-0-FB-STK--0.0---SMART--USD-----BUY-42-MKT-------0--1-280-0-0-0-0-0-0--0--------0---1-0---0---1-1--0------0-----0-----------0---0-0---0--0-0-0-0--1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-0----1.7976931348623157e+308-----0-0-0--

This indicates that your GoodAfterTime field was not transmitted to IB, which explains why the MKT order executed immediately.
The reason this was not transmitted is possibly because you did not use the correct field name - I think it should be "goodAfterTime" (lowercase g) and not "GoodAfterTime"


 

I hope you are right. ( sounds logical)
However the TSW API clearly stipulates an upper case.........
string? ?[get, set]
As well PYcharm did auto complete it......
Will check on Monday.

P.S how do you diduct from the??debug log extract,?that "GoodAfterTime?" field was not transmitted to IB?

Toda Raba, cheers, Erez


 

It was immediately clear from the logs that your GAT string was not included in the request to IB, the rest was simple deduction.

Here's was a MKT order with GAT should look like in the logs - in this case, GAT="20210117 15:20:00", note the?highlighted?part:
19:57:08:053 <- 3-39-1131846390-0-IBM-STK--0.0---SMART--USD----sell-1-MKT-0.0-0.0-GTC---O-0--1-0-0-0-0-0-0-0--0.0-20210117 15:20:00------0---1-0---0---0-0--0------0-----0--------0---0-0--0-
p.s. your log might look a bit different [extra/missing fields etc.] depending on the IB API version that you're using, but it's very similar in all versions of recent years?


 

You also need to set the TIF parameter to "GAT", otherwise the GAT value will be ignored (the default TIF is "GTC" = Good Till Cancelled)