Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Held orders and cancels

I noticed that Quantopian started detecting that an order's status was 'held' by IB while IB was finding a short borrow locate. Two questions:

  1. What is the 'official' way of programatically checking that the order is in the held state. I see that it corresponds to a order.status=4 and that the order.reason=u'Order held while securities are located' but checking for either of those seems a bit fragile since '4' is a magic number? Is there a list of status codes somewhere?

  2. My code tried canceling that order multiple times but none of the cancels went through. Why? I've never had problems canceling held orders before and even with this one, I was easily able to cancel it manually w/ IB.

4 responses

Hi Alex,

You can find the root 'status' list here, as it's actually stored in the open-source Zipline project: https://github.com/quantopian/zipline/blob/master/zipline/finance/blotter.py#L38 I'll file a ticket internally to move those over to our online documentation as well.

Your held-order cancels are failing due to a bug in our implementation. I'm working on a patch right now and will follow up when it is deployed. Thanks for the report!

Cheers,
--JD

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Hi Alex,

We've deployed a patch for the unable-to-cancel-held-orders bug, so as of tomorrow's live-trading open everything should work as intended. Apologies for the disruption and thanks again for the report!

John,

It seems that this is still an issue. I'm paper trading on IB and found myself in the same situation (order held until securities are located), but the call to cancel the order in the algorithm seems like it didn't work. Happy to share more information if need be to troubleshoot. Thanks.

Sari, please hit the "Contact Support" menu item in the upper right, and tell us about the problem. Thank you.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.