There's a pretty good tutorial on how (and why) to use pipeline in the tutorials section https://www.quantopian.com/tutorials/pipeline.
To get you started maybe an algorithm something like the one that's attached. It places orders at different times than the original and because pipeline always gets the previous days prices, it looks at a bit different returns. Also, it shorts positive returns and goes long on negative returns. This is the stated goal in the post however the code that was attached was just reverse (more like a momentum strategy). Note that the leverage is about 2 because of the weighting that was defined in the original code.
Also, the code in the original algorithm probably isn't working exactly as expected. The ordering lines
order_target_percent(longs, 1/(len(context.securities_long)))
and
order_target_percent(shorts, 1/(len(context.securities_short)))
Should be as follows (notice the floating point 1.0) and also in order to short a stock one needs to order a negative qty.
order_target_percent(longs, 1.0/(len(context.securities_long)))
and
order_target_percent(shorts, -1.0/(len(context.securities_short)))