I have a monthly rebalance algo, and it rebalances 10 stocks each month. I want to separate this single updated positions stock list into 2 separate lists, a liquidate stock list and a buy stock list. This is for the purpose of going into 2 Debug lines, then emails and text messages.

I've tried getting these lists to come out as a single string, but just can't figure it out, and have worked around it to at least iterate through the list, but this gives a Debug output line for each buy and sell stock symbol, and I don't want 20 messages on each rebalance, I just want 2. Can anyone help?

def rebalance(self):
        sorted_symbolData = sorted(self.symbolDataDict, key=lambda x: self.symbolDataDict[x].Volatility())
        # pick the stocks with the lowest volatility
        long_stocks = sorted_symbolData[:self.stocks]
        stocks_invested = [x.Key for x in self.Portfolio if x.Value.Invested]
        # liquidate stocks in the current portfolio that are not in the new positions list. 
        for i in stocks_invested:
            if i not in long_stocks:
                self.Debug("Sell: " + str(i))
                self.Liquidate(i)
        # determine the new stocks to buy that are not currently in positions.
        for i in long_stocks:
            if i not in stocks_invested:
                self.Debug("Buy: " + str(i))

thanks!

mark