Can I wait before selling a losing stock that turned non permissible

Salam everyone, I invested in a stock which was haram unknowingly. I lost 60 percent of my capital on that stock. Is it permissible to rebuy that haram stock after I sold it at 60 percent loss in order to recoup my losses?

Salam again,
Another query I forgot to mention is if a firm’s impure income is at 7 percent. I have heard of the 5 percent rule. Does this mean, any profits I make on it, I have to give 7 percent of it away to charity or do I have to give all of the gains to charity?