SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue May 21, 2019 6:11 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Nov 30, 2007 2:33 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6812
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();
  }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 26, 2007 9:04 am 
Offline

Joined: Sat Nov 17, 2007 8:03 pm
Posts: 6
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 21, 2008 5:37 pm 
Offline

Joined: Fri May 25, 2007 1:57 am
Posts: 24
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.


Top
 Profile  
 
 Post subject: Bracket Order Supported
PostPosted: Tue Mar 02, 2010 4:18 am 
Offline

Joined: Fri Feb 12, 2010 9:11 am
Posts: 10
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?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2010 8:52 am 
Offline

Joined: Sat Dec 05, 2009 8:17 pm
Posts: 8
Is this a dead forum? No one bothers to respond.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2010 9:08 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6812
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2010 9:25 am 
Offline

Joined: Sat Dec 05, 2009 8:17 pm
Posts: 8
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2010 9:38 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6812
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


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 15, 2010 9:43 am 
Offline

Joined: Mon Mar 29, 2010 8:58 am
Posts: 3
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. :)

_________________
I'm a web designer and here are two of my sites
how to make money online and
debt solutions


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group