The one who has repented from riba should not take anything but the capital of his wealth only, because Allaah says (interpretation of the meaning):
“but if you repent, you shall have your capital sums. Deal not unjustly (by asking more than your capital sums), and you shall not be dealt with unjustly (by receiving less than your capital sums)”
It is not permissible to take anything more than that; if a person has taken it he must get rid of it by spending it on charitable causes.
In the question there are two issues which have nothing to do with one another, and we must deal with them separately: the interest which has been taken, and offsetting the depreciation in the value of shares with this interest.
With regard to the first issue: putting money in a riba-based bank and taking more money than the original capital. The scholars of the Standing Committee said:
The interest which the bank pays to depositors on the money that they deposit is considered to be riba (usury, interest), and it is not permissible to make use of this money. The person must repent to Allaah from depositing money in riba-based banks, he should withdraw the money that he deposited and the interest, then keep his original amount and spend the interest in charitable causes, such as on the poor and needy, renovating public facilities, and so on.
Fataawa Islamiyyah, 2/404.
Shaykh ‘Abd al-‘Azeez ibn Baz (may Allaah have mercy on him) said:
With regard to the interest that the bank gives you, do not give it back to the bank and do not consume it, rather spend it on charitable causes such as giving it to the poor, renovating public washrooms, and helping debtors who are unable to pay off their debts.
Fataawa Islamiyyah, 2/407
With regard to the second issue: offsetting the depreciation in the value of shares with this interest, it is not permissible to do this, because it is not permissible for you to take this money and benefit from it, as stated above.
The person who buys shares has to bear losses in the value of his shares from his own money; he does not have the right to offset those losses with money that he acquires from haraam sources.
The fact that he entered into this transaction when he was unaware of the fact that it is haraam means that he is absolved of any sin; he is excused by the fact that he did not know. But that is not a reason for allowing him to benefit from the interest by using it to offset these losses.
And Allaah knows best.