Has anyone figured out how to place and execute an Overnight order using the IB API. All I get is the error message: ErrorCode=10329 ErrorMsg=This order will be directly routed to OVERNIGHT. Restriction is specified in Precautionary Settings of Global Configuration/API. Yet the same trades execute immediately when I try them from TWS. I followed the instructions in https://www.interactivebrokers.com/campus/ibkr-quant-news/api-overnight-trading/ but the instructions do not specify what values should be placed in the Order Tif, IncludeOvernight or OutsideRth fields.
Something to note is that the API throws regular notifications as errors. They use the same field for every notification. If you look at the message, it is not really an error. They are just telling you that the order went through and will be redirected. If you want to change that behavior you have to edit your gateway settings.
I realize that. The problem is that when I enter the same order manually in the TWS GUI, it is immediately executing, and I can't figure out what I am doing different. I even looked at the TWS audit, but unfortunately the audit field names are completely different than the API field names.
You could try doing this using ib_insync with Python. This would allow you to take a look at the order object to see which fields have been set and which fields are available. You also may be able to look at the trade that executed via TWS using this method to see how the various fields were set.
Here is what ChatGPT had to say: If you want to place an overnight order on the NASDAQ exchange using ib_insync, you'll need to specify the "TIF=GTD" (Good-Till-Date) or "GTC" (Good-Till-Canceled), along with outsideRth=True. NASDAQ Overnight Trading via IBKR Interactive Brokers supports NASDAQ's Extended Trading Hours (ETH), which includes pre-market (4:00 AM - 9:30 AM ET) and after-hours (4:00 PM - 8:00 PM ET). Placing an Overnight Order on NASDAQ (Using ib_insync) (python) from ib_insync import * # Connect to IB Gateway or TWS ib = IB() ib.connect('127.0.0.1', 7497, clientId=1) # Use 7496 for live accounts # Define NASDAQ-listed stock contract contract = Stock('AAPL', 'NASDAQ', 'USD') # Ensure 'NASDAQ' as the exchange # Define the order order = Order( action='BUY', # 'BUY' or 'SELL' orderType='LMT', # Limit order lmtPrice=175.50, # Set your limit price totalQuantity=100, # Number of shares tif='GTD', # Good-Till-Date (valid for overnight trading) goodTillDate='20240213 04:00:00', # Set expiration in UTC (YYYYMMDD HH:MM:SS) outsideRth=True # Allow trading outside regular hours ) # Place the order trade = ib.placeOrder(contract, order) # Print order details print(trade) Key Settings for NASDAQ Overnight Trading Exchange: 'NASDAQ' Ensures the order is routed to the NASDAQ market instead of IB's SMART routing. outsideRth=True Allows the trade to execute outside regular hours (pre-market & after-hours). TIF (Time in Force) = 'GTD' or 'GTC' 'GTD' (Good-Till-Date) lets you specify a time until which the order remains valid. 'GTC' (Good-Till-Cancelled) keeps the order active until it's canceled or executed. goodTillDate='YYYYMMDD HH:MM:SS' Required when using 'GTD' to specify expiration time in UTC. Extended Trading Hours for NASDAQ Session Time (ET) Pre-Market 4:00 AM - 9:30 AM Regular Hours 9:30 AM - 4:00 PM After-Hours 4:00 PM - 8:00 PM
Very interesting Gary. ChatGPT seems to have some good suggestion (i.e. with the TIF and GoodTillDate), which I will give a try. But I must also mention that ChatGPT seems to somewhat confuse Overnight trading with Extended Trading. Thanks