Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Request for Pointers: Stocks portfolio - Daily long only adjustment for trending stocks in list

Hello All

I am both a Python newbie & Quant newbie.

I am sure that the idea would not be new so I am looking for pointers for similar trading systems, similar ideas, papers discussing something similar or same, preferably from someone with backtested results of what works & how well.

I wish to backtest & evaluate, a portfolio of stocks, preferably high volume/volatility ones, maybe constituents of indexes. The portfolio is readjusted daily. Losing stocks are sold if anything is to be bought. If there are no losing stocks, least trending stocks are sold. Highest trending ones are bought everyday.

Second permutation would be buying on a few days swing but top trending ones...don't have much idea about this.

Would like to see what slippage & transaction cost does to such a long term portfolio and of course what happens to the capital?

Things of question are the best method & timing of determining the Trending Stocks and if it is of any use to have a percentage of fixed holding/component or bias for higher position size of most volatile & highest volume stocks.

Hope you guys can guide a newbie.

Thanks.
Sanjay.

1 response

Hi Sanjay,

Welcome to Quantopian! I would suggest diving into an algo and testing your own ideas. I think in this case, the Pipeline API would be helpful, as it will allow you to create factors for all 8000+ securities daily. It also allows you to rank and filter them so you could group stocks into "trending" bins (you can also look at things like volume/volatility). As a starting example, check out this mean reversion example - it's a relatively basic sample algo that you can change around.

If you find this is too much to start, check out these Getting Started tutorial videos. They don't cover Pipeline, but they go over some of the basic concepts of writing an algorithm on Q.

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.