Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
getopenorder() is keep growing. I am not sure how to understand this

I have a backtest where number of position with openorder is keep growing. Could you any one tell me what is going on?
You can see from the custom window where open order (along with leverage and #of positions).

6 responses

Hi Ujae,
You are running into an accumulation of delisted securities in your portfolio. There is a workaround explained here.

The pipeline API allows you to have a much larger universe easily, but it does cause this problem to be more noticeable. We'll hopefully be working on a better resolution to delisted securities soon.

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.

To add to Karen's response, if you want to live trade this algo, you will have to implement a more preventative guard against delisted securities. Only trading every 2 years exposes you to the possibility of one of your held positions going delisted but you can take measures to try to mitigate this risk. Have you tried being more selective with your market cap filter, or have you tried adding a dollar volume? This might help to avoid buying stocks that go bankrupt!

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.

Err, I would just like to add that it's not that simple - if it were simple to identify which stocks were going to go bankrupt, you've just won the lottery - short them all and retire.

@Simon, you are 100% correct, which is why I'm only suggesting that it might help to mitigate the risk :)

I mostly wanted to point out the fact that looking at end_date is using lookahead bias which does not translate into live trading. Sorry if that wasn't clear!

Thanks Karen and Jamie,
If I understood your example, workaround explained here, correctly, utilizing end_date has more to do with fixing problem during the back testing. In real life trading, you won't have nicely warned context.stock.end_date telling you that you have to get out. Correct?

I am thinking that is why Jamie said "end_date is using lookahead bias ". I am little slow, but I think I am getting there.

Now, how about using "adding a dollar volume". I would guess that is more preventive measure.

Of those securities whose value went zero, I noticed two patterns, one that steadily lost value vs that boom disappeared. So I am guessing that the steadily lost value is dying business and the boom disappeared are more like acquired company. I think I should at least know how to deal with something that have been losing value more than 75% since purchase. As to acquired, what can possibly done about it? I would just leave it as is for the back testing, because at least I know it probably was worth something since the acquisition. I don't think anyone can easily detect acquired company in advance.

We've made an update to how the backtester handles delisted securities and removes them from your portfolio. You can learn more about it here.