Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Why does "long/short on recently good/bad stocks " strategy perform so bad?

The strategy is one of the most naive: once per month rebalance the portfolio and go long on the best performing stocks and short on the bad ones.

I understand that such a naive strategy cannot work, but why? Why statistically the good stocks start losing money when you pick those and the bad ones start making money?

I am pretty sure there are good explanations for this behaviour and I wonder if someone knows the answer.

Thank you!

6 responses

Are these lines correct:

    context.shorts = ranks.head(context.num_short_securities).order(ascending=True)  
    context.longs  = ranks.tail(context.num_long_securities).order(ascending=False)  

It looks like a double negative, and you'll end up getting the same subset for longs and shorts

They should be correct. Have a look at log messages, they print the long/short stocks so that you can double check.
Also, if the long/short were identical the algorithm will end up having no positions.

Please note that head/tail are applied before sorting:
short = take first entries (head) and sort them ascending
long = take last entries (tail) and sort them descending

If you are certain that "good stocks start losing money when you pick those and the bad ones start making money" then just short the good stocks, and go long on the bad ones. Not sure that'll work though, based on the attached backtest. There's a problem with leverage, too.

@Grant, both my and your backtests seem in accordance with the random walk theory and I wasn't expecting to prove that theory wrong ;)
I was hoping that someone had an intuitive explanation of this unpredictable market behaviour. I know it works like this, but why?

You might look into https://en.wikipedia.org/wiki/Efficient-market_hypothesis and such.

The flip side of the coin is that if one finds a naive strategy that appears to work, how does one determine that it actually works? And how does one know when to stop applying it, if it fundamentally no longer works?

I was hoping that someone had an intuitive explanation of this unpredictable market behaviour. I know it works like this, but why?

Mostly because commissions/slippage. Without those it will most probably look much more like random walk.