Employer stocks benefis

Assalamou alaykum,

I work in a company in the financial sector, which I believe is not permissible to invest in.
My question is : Is it possible to put certain percentage of my salary buying the company stocks which will be matched by the employer, then purify the gain after selling the stocks ?
If possible, is there an easy way to calculate that amount/ percentage?

Jazakomo Llah khayran