开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Can I combine a bracket order with a MOC (Market on close) order - Invalid OCA handling method


 

Hi,

I am wondering if it is possible to add? MOC order to a bracket order group?

Actually currently it doesn't work for me.

Here is what I do:

- Creating the parent order

- Creating three child orders: ProftiTaker, StopLoss and MOC

ProfitTaker and StopLoss will be created correctly, but for the MOC order I get the error:
"Invalid OCA handling method"

So my assumptions is, it is not possible - or are there specific settings to take into consideration.

Thanks
Johannes


 

MOC orders have many limitations and special requirements that make them incompatible with "One Cancels All" groups, Johannes. And internally, bracket orders are basically OCA groups. Take a look at "". NASDAQ MOC orders, for example, cannot be cancelled after 15:50 EST.

Are you trying to participate in the Market on Close auction (e.g. you really need the MOC order type), or are you simply trying to close the position automatically at the end of the trading session? We successfully use bracket orders with an additional third child order that closes the position a few minutes before the market closes. Basically just a MKT type order with a time condition.

闯ü谤驳别苍


 

Hi 闯ü谤驳别苍,

thanks for your tips. Actually it sounds very obviously that a MOC order can not be part of OCA group if cancelling is not always possible. I wasn't aware about that.

Now I will change my code to using?ibapi.order_condition.TimeCondition.

Also I am wondering, if it it can be done simple setting order attributes as below:

order.Tif = 'GTC'   
order.ActiveStartTime =?'20220621 15:20:00'?# Defines the start time of GTC orders., Valid format: YYYYMMDD HH:MM:SS.?

I will play a little bit around and do some paper trading next Tuesday (when NYSE) is open again.
Guess this order specifications types are only doable in NYSE.


 

On Sun, Jun 19, 2022 at 06:35 AM, <johannes.kreckel@...> wrote:
order.Tif = 'GTC'
Take a look at my sample code in this thread -?/g/twsapi/message/49108?to see how I have modeled the FlattenOrder to do what you are doing using the GAT order type.


 

To successfully place a MOC order within an OCA group, you must set the OCA mode to reduce (without protection), and expect that despite this the OCA event will entirely?cancel rather than reduce it.