¿ªÔÆÌåÓý

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

MOC orders and ocaGroup


 

Has anyone worked out how to handle MOC (Market on Close) orders inside an ocaGroup?? There doesn't seem to be a valid ocaType setting for a MOC order: 1 & 2 return error 201 ("Order rejected - reason:Invalid OCA handling method."), and I don't want to use/haven't tried 3.

I can work around this of course by manually (via code) cancelling other orders in the group and submitting the MOC as a standalone order, but I'm surprised that the API requires this.? In any case it's not ideal, because I would like the other orders (stops) to remain in place until the MOC order triggers.?

Is there no way for a MOC order to sit inside a ocaGroup?


 

Does TWS allow your construct when you key that in manually?

Reason why I ask is that I just went through a debug cycle for a very similar issue. In my case it was a MKT order with TimeCondition set to five minutes before market close that failed when transmitted in an OCA group. But it worked when entered in TWS through the "Order Ticket" screen in TWS.

So I compared the order object that I submitted via the API with the one that TWS created and quickly found the initialization issue in my code.

´³¨¹°ù²µ±ð²Ô


 

Great suggestion, thanks ´³¨¹°ù²µ±ð²Ô. Manually keying a MOC order in an ocaGroup with a trailing stop and a limit stop gives these errors:

Reduce others:? OCA handling method mismatch
Reduce others (overfill):? Invalid OCA handling method
Cancel others: Invalid OCA handling method

It would seem to indicate MOC orders can't operate in an ocaGroup; but the error message are odd, as they seem to imply that there is a valid way of doing it.


 

That's too bad. Maybe the MKT plus TimeCondition near market close we use for futures can work for you, too.


Nick
 

You'll probably have to talk to IB to get an official answer.

If I remember right MOC orders can't be modified within 10 minutes of the close. Cancelling one of the other orders in this time would result in just the MOC order remaining live which would leave you with an incomplete group.

IB may be trying to prevent this situation and so disallows MOC orders in OCA groups.

On 10/15/2021 1:19 AM, David Walker wrote:
Has anyone worked out how to handle MOC (Market on Close) orders inside an ocaGroup?


 

MOC orders can be placed in OCA groups in unprotected-reduce mode. That's the single mode that has worked in my experience?with MOC orders, with an additional caveat that the closing order will likely not actually be reduced at any stage but only cancelled completely once the other order is completely filled.