SmartQuant Discussion
http://www.smartquant.com/forums/

How to submit a bracket order
http://www.smartquant.com/forums/viewtopic.php?f=64&t=6226
Page 1 of 1

Author:  Dr. Anton Fokin [ Fri Nov 30, 2007 2:33 pm ]
Post subject:  How to submit a bracket order

The code below uses OnOrderFilled event handler to submit legs of bracket orders and OCA (One Cancels All) group to cancel other leg of bracket order if take profit or stop loss order gets executed.

Code:
Order buyOrder;
Order sellOrder1;
Order sellOrder2;

int OCACount = 0;

public override void OnBar(Bar bar)
{
  if (EntryCondition)
  {
    buyOrder = BuyLimitOrder(qty, 100);
    buyOrder.Send();
  }
}

public override void OnOrderFilled(Order order)
{
  if (order == buyOrder)
  {
    OCACount++;

    sellOrder1 = SellLimitOrder(qty, 110);
    sellOrder2 = SellStopOrder(qty, 90);

    sellOrder1.OCA = "OCA " + OCACount;
    sellOrder2.OCA = "OCA " + OCACount;

    sellOrder1.Send();
    sellOrder2.Send();
  }
}

Author:  CPTRADER [ Wed Dec 26, 2007 9:04 am ]
Post subject: 

Hello,

I think it would be best if Bracket orders were available as a default order type NOT involving any extra coding.

Can this feature be added?

Thank you.

Author:  dareminator [ Thu Feb 21, 2008 5:37 pm ]
Post subject: 

Thank you for the above code, which infact gets the job done. However, it is not as robust as sending the primary and bracket components as an atomic transaction:
Code:
parentOrder = BuyLimitOrder(qty, 100);
sellOrder1 = SellLimitOrder(qty, 110, parentOrder);
sellOrder2 = SellStopOrder(qty, 90, parentOrder);

parentOrder.Send();


If the bracket order could live at my broker's servers, my back would be covered against connection failures, partial fills (where OnOrderFilled doesn't get invoked), crashes in my code, or a myriad of other low-frequency unanticipated things.

It is possible to code guards against manyof these conditions through sufficient periods of testing with live market data -- but the most robust solution would still be the atomic send of parent-and-multiple-child-orders.

IB API supports the above syntax and it would be a valuable feature to have in OpenQuant.

Author:  jeremytang [ Tue Mar 02, 2010 4:18 am ]
Post subject:  Bracket Order Supported

I know there are ways to manually code "bracket" orders using event methods, but there's some inherent problems and risks associated with a manual bracket order when it's not handled by the broker...

Has this been implemented yet?

Author:  tradersu [ Mon Jun 21, 2010 8:52 am ]
Post subject: 

Is this a dead forum? No one bothers to respond.

Author:  Dr. Anton Fokin [ Mon Jun 21, 2010 9:08 am ]
Post subject: 

Why dead? Implementing another order type is not just about adding a flag or an extra field to the order object sent to a broker. We should also add support for this order type in the execution simulator and in the order manager, i.e. send and handle two orders instead of one bracket order if bracket order type is not supported by the broker (similar to OCA group). It's a complex task, so that it will be implemented when we are done with all other (more) important issues.

Regards,
Anton

Author:  tradersu [ Mon Jun 21, 2010 9:25 am ]
Post subject: 

Dr. Anton Fokin wrote:
Why dead? Implementing another order type is not just about adding a flag or an extra field to the order object sent to a broker. We should also add support for this order type in the execution simulator and in the order manager, i.e. send and handle two orders instead of one bracket order if bracket order type is not supported by the broker (similar to OCA group). It's a complex task, so that it will be implemented when we are done with all other (more) important issues.

Regards,
Anton


Sorry for being rude but the thread was unanswered for a long time. You could have responded the same to previous poster(s).

Let me explain the importance here. I've a bracket order that should only become active when my parent order is filled. Since parent order is a LIMIT order, we don't know about the fill... And if my internet connection is lost during fill, the bracket will never come to action :-(

Not sure about other brokers but IB has a concept of "Parent Order" and child order (usually bracket) will only get active when parent order got the fill. This whole thing is ATOMIC (fully managed at IB server). So computer crash, internet disconnect etc won't affect it.

http://www.dinosaurtech.com/forums/topic.php?id=105

Does it sound serious? I guess YES.

Author:  Dr. Anton Fokin [ Mon Jun 21, 2010 9:38 am ]
Post subject: 

Well, we do understand that this issue is important, but what kind of answer do you expect from us if this feature is not implemented yet? Actually we want to support ALL order types supported by IB and this is on our todo list but we currently don't have enough time for this since we are working on high priority OQ bug fixes and features and on the new architecture.

Regards,
Anton

Author:  joetraff [ Sun Aug 15, 2010 9:43 am ]
Post subject: 

tradersu wrote:
Dr. Anton Fokin wrote:
Why dead? Implementing another order type is not just about adding a flag or an extra field to the order object sent to a broker. We should also add support for this order type in the execution simulator and in the order manager, i.e. send and handle two orders instead of one bracket order if bracket order type is not supported by the broker (similar to OCA group). It's a complex task, so that it will be implemented when we are done with all other (more) important issues.

Regards,
Anton


Sorry for being rude but the thread was unanswered for a long time. You could have responded the same to previous poster(s).

Let me explain the importance here. I've a bracket order that should only become active when my parent order is filled. Since parent order is a LIMIT order, we don't know about the fill... And if my internet connection is lost during fill, the bracket will never come to action :-(

Not sure about other brokers but IB has a concept of "Parent Order" and child order (usually bracket) will only get active when parent order got the fill. This whole thing is ATOMIC (fully managed at IB server). So computer crash, internet disconnect etc won't affect it.

http://www.dinosaurtech.com/forums/topic.php?id=105

Does it sound serious? I guess YES.

Yap the answer is yes.
Right you are. :)

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/