Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
"Chimp" algorithm: 100 randomly selected S&P 500 stocks, equal-weight, buy and hold forever

I wrote this algorithm inspired by Joshua Kennon's excellent blog post on S&P 500 index investing. The results, supported by quite a bit of academic literature, are quite good. I tested versions of this algorithm multiple times over multiple different starting time periods and I have not yet found a run where it doesn't outperform the S&P 500 index and numerous runs where it outperforms the S&P by a good margin.

Notes: Because of limitations of how Quantopian manages dividends (it doesn't tell you where they are coming from, just deposits them in portfolio.cash), I am assuming reinvestments into SPY. In real life, I would plan to just set up all of the stocks on a DRIP dividend reinvestment program, which is free of commissions. In addition, I am ignoring transaction costs because this is a buy-and-hold-forever algorithm and it shouldn't affect the answer very much with a sufficiently large portfolio.

9 responses

You might find this interesting too: why-random-portfolios-appear-to-outperform-benchmarks

You have a bit of a bias here because before 2015 you had no idea if the companies would have existed or if they would have been included in the S&P 500. Notice that if you start the backtest from 2015 there seems to be absolutely no alpha and it more or less follows the market.

Fundamental flaw - survivorship bias.

Argh-- totally fair and correct. The whole "no peeking into the future" thing has subtle traps. I'm still curious, though, so when I have a bit of time I'll try to correct this by having it load the S&P components that were available at that time.

OK, sending this out before I leave for the office. This version uses Pipeline to randomly select 100 of the top 1000 equities weighted by market cap at the time-- S&P is fairly arbitrary anyways. Over several runs, alpha is closer to zero. Interestingly, at least on a few runs I tried, this algorithm performs worse in recent years than dates starting a decade or more ago. Anyways, thanks all for the comments!

Now try excluding stocks which have 0 or negative momentum over the lookback period...give such stocks a zero weight but do NOT give the extra cash to the remaining stocks. This will cut both DD and Vol.

Luca

I had a quick read through that article referenced in the other Q thread you refer to.

As far as I can see it does NOT trash such alternative passive index strategies per se. To do so would be truly stupid if empirically they work (in backtesting at least!).

All the paper is saying is that such strategies work for reasons different to those the "inventors" assumed.

Namely small cap and value tilts.

I do find such semi academic articles tend to be sniffy and condescending

If the system works trade it. I guess that is one of the delights of the hedge fund world. It tends to stick two fingers up at dull, stifling convention.

I have nothing against rigorous research and have always tried to make my own research as unbiased and thorough as possible. But if something works, if a trading scheme is not curve fit who care if the reason it works is because it favours value stocks, or growth stocks or value stocks?

But thank you very much indeed for highlighting that thread. I am no admirer of the sort of loud mouthed self congratulatory article on the referenced website in that other thread. However stock picking is clearly a waste of time and market cap weighted indices clearly have their limitations as well as their part to play.

So what I say is "good on you Edward Park". I love these sort of experiments and have carried many out myself on random portfolios which include de-listed stocks.

I'm only trading my one model TAA1 at the moment but I expect to add a few such as the random approach to my portfolio of systems. To hell with convention and clients and talking heads. No wonder the "hedgies" invented themselves and their way of life and business!

Edward, I don't suppose you're the Ed Park from BM are you?

I love it!
I am totally going live with it.
im doing a "lucky 13 list" of random stocks every month.
im going to buy /sell list on market close if over/under 15 day average for last close and current close. i still think i shouldn't have any open positions trading under its average. am i all wrong?
ill do the pipeline thing for market cap and trade volume to grab my randoms from.
I'll thank you now, and again when im outperforming sp!
thank you!
tyler