Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
2 Minute Portfolio

Hey guys,

I'm new here and don't know much about python yet, though i want to backtest an idea that i have come across from an article some time ago.

It consists of building a portfolio of the two market cap leaders in all 10 sectors which pay dividends. Every end of year, you refresh the list with the new market cap leaders. It is a very basic portfolio strategy and when implemented on the Canadian stocks, it exceeded the market return.

I want to backtest this with U.S. stocks to verify if the strategy is still plausible. Can anyone provide any input on how to approach this. Any help would be much appreciated.

Thanks

1 response

Hello Achot,

I'm not sure how you'd use the Quantopian backtester to define the portfolio, but would you be able to define it off-line, year-by-year? Basically, for every year you'd like to backtest, you would provide a list of the market cap leaders to be in your portfolio (20 stocks in all, if I understand correctly). There are more elegant ways in Python, but a simple implementation would be:

context.stocks_2006 = [list of securities]  
context.stocks_2007 = [list of securities]  
etc.  

Then you would do a re-allocation at the start of every calendar year, which is doable in Quantopian once you have defined the annual portfolios. Would you do an equal weighting of each stock, or would you weight by market cap or some other factor? Either way, you can code weighting into the Quantopian backtester.

Regarding your unfamiliarity with Python, you might have a look at some of the links here:

https://www.quantopian.com/posts/learning-python

Grant