¿ªÔÆÌåÓý

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

Re: Is it possible to place order at 15:59 or 16:00 and get a fill?


 

MOC/LOC orders require that TIF is set to "DAY".

To put MOC order in the bracket, the following settings must be used for the bracket order peers:

moc.ocaType = 3;
trailingStopLoss.ocaType = 3;
This is to allow the MOC order to work in an OCA group of the bracket order children, countering the concern that Juergen raised. Although "3" for this setting is generally used to reduce the mutually exclusive orders by the size of either order's fill without overfill protection, with MOC/LOC order it just means "cancel the other order completely" because IBKR does not offer reduction of MOC/LOC orders while any other?ocaType?setting will resulting in the MOC/LOC order rejection. The result would look like this:



You do not need any time condition for the MOC order as it will activate automatically once the exchange transitions from regular trading to the closing auction (and IBKR won't allow order conditions on MOC orders, though if you need to enable the order at a certain time for any reason, you can always use Good-After-Time (order.goodAfterTime) property, which, in addition to working with more order types than time conditions, is also easier to use as it takes a single line of code to configure).

Referring to Juergen's concern again, since MOC orders indeed cannot be activated and cancelled after a few minutes before close (10 minutes for submission and 2 minutes for cancellation on NYSE, and 5 minutes for submission and 10 minutes for cancellation on Nasdaq), it might be a good idea to cancel or suspend the other orders at those cutoffs so as to avoid accidentally running into an overfill, although these guards would certainly complicate the code and kind of defeat the simplicity advantage of the MOC order in that it requires zero timing efforts. Today's liquid hours closing time can be learned from ContractDetails for the respective stock or from a Python package such as exchange_calendars. If you choose the MOC path, and seeing that you already use GTC TIFs, I believe temporary suspension of trading is enabled for GTC orders with?order.activeStopTime?property (vis a vis?order.activeStartTime, though I'll admit I never used these properties myself yet).

--
Best,
DS

Join [email protected] to automatically receive all group messages.