Hi everyone,
I'm trying to build a strategy that ranks stocks according to their bullish momentum and buys every month the top 10 of them and takes a short position in SPY, as large as all long positions together.
Unfortunately, as you can see in the backtest result, my implementation doesn't remain at a constant total of 11 positions during the test period, but keeps some from the previous month. I've been looking for my mistake in the rebalance function for a long time, but I just can't find it.
Does anyone see what I'm doing wrong?