By investing in publicly traded stock, you’re purchasing part ownership of the means of production and making profits off someone else’s labor. I don’t see how you can even justify owning small amounts of stocks when it contributes to such awful things on a massive scale.
If all leftists stopped investing, it would not stop capitalism, and stopping investing isn't a viable way to change society. I don't think leftists should be into deontological ethics.
But I would be suspicious of a leftist who made their living from stocks.