I want only one position to be open at a time. The algorithm can't buy other securities until the portfolio is empty. But my code doesn't work that way. In fact, the algorithm buys several different securities at the same time. What's wrong with the code?