Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
order_target_percent() weird behavior

I copied code from www.quantopian.com/tutorials/pipeline#lesson12 and I slightly modified it.
I added another pipeline, changed order_optimal_portfolio() to for loop and added another for loop to my_rebalance function that longs all stocks that are not shorted by first for loop. When I comment out one of that two for loops it's working normaly but when I run backtest with both loops I get really weird results. I got the same with order_optimal_portfolio().Leverage is going up overtime and longs and shorts count is going up and down which doesn't make any sense to me.

2 responses