Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Do Growth Stocks Beat the Market?

Hi,

I adapted a simple algorithm to test a selection of stocks (based on #Fundamentals data from Morningstar) against the market. The goal is to test whether growth stocks (those with P/E higher than a certain value) beat the market. One just need to tweak the DollarVolumeUniverse parameters and the P/E ratio filter.
I could use a help though: I cannot manage to avoid the cash being negative... I don't understand what's happening as I am always using order_target_percent to make the total be 100% (even a little less, 95% but it's not working anyway).

Cheers,

Ilidio.

4 responses

Hi Ilidio, nice algo!

Your algorithm was dipping into negative cash because order_target methods only consider the status of filled orders when making calculations. They aren't aware of open orders. As a result, it may lead to overfills/underfills as it tries to correct itself. This is one of the rough edges of the platform and we're looking to make it easier! In the meantime, I added a couple lines to your algo to check for any open orders.

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.

While typing, Alisa's response appeared, guess I'll post anyway as this is a little different.
Couple of routes here, one is to skip ordering if get_open_orders(stock) returns something (place a breakpoint under it and re-run that in the console window to turn the lights on) and the other (commented out) only avoids ordering if a sell just happened.

Hi Alisa / Gary,

Thanks for pointing that out! I changed the algo a little bit, to try to close the open orders before the next rebalancing at the start of next month - I give 20 days time and then close any open orders.
On rebalancing, I check for open orders with a print_open_orders method and it is showing nothing, so I think the fix is right.
However, the cash is still going negative sometimes, I think it is because of stocks getting de-listed and remaining in the portfolio - the algo tries to sell them but can't, and so the cash remains negative (on rebalancing, the algo calculated it would be able to collect cash from these orders, but they never get executed...)
I real life I think one would know a few days in advance if a stock gets delisted, and could act accordingly. How can we simulate this in Quantopian?
Any suggestions?

Anyway, congrats to Quantopian for this #Fundamentals feature, it is very useful!

Cheers,

Ilidio.

Ilidio, here's a couple threads that show how to deal with delisted stocks in your portfolio:

https://www.quantopian.com/posts/when-a-company-gets-acquired-my-portfolio-still-owns-shares-of-the-original-company-is-that-right
https://www.quantopian.com/posts/add-and-remove-securities-using-an-external-file-fetcher