You probably know all this but in .rank(), all values fed to MaximizeAlpha are positive, just needs some negative for shorting. One route:
'testingFactor': testingFactor.demean()
... to shift the middle of ranks to 0. Or like this backtest.
Another thing you can do to understand this is, in your version with : MAX_SHORT_SIZE = -0.05 and MAX_LONG_SIZE = 0
... place a minus sign in front of the input to opt. That makes all of the ranks negative and you'll see trades.
opt.MaximizeAlpha( -context.output['testingFactor'] )
In multiplying them all by -1, the highest positive becomes the lowest negative. Instead they can all be shifted downward to negative to see what happens like this. So if the top rank is 2063, it would become 0 actually. Rank 2062 would become -1, 2061 becomes -2 etc. The -= operation is shorthand for context.output.testingFactor = context.output.testingFactor - context.output.testingFactor.max()
def rebalance(context, data):
context.output.testingFactor -= context.output.testingFactor.max()
I added log_data(), helpful to see what pipeline is delivering, and becomes more elaborate when more than one column