It seems that as a foreigner you have to pay capital gains tax on investment income (on the sale of stocks). Does anybody have any insight whether this can be avoided and how?
in general capial gain is always paid in the country where the entity object of the transaction is located (always true for capital gain on real estate).
To be absolutely sure, you should look at the double taxtation treaty between Portugal and the country where the sold asset is located.
A way to create a more efficient structure could be to use an holding company through which execute the investments and then distribute dividends from the company to the shareholder.
If the shareholder is Portugal NHR and the holding is located in a country without withholding tax, the dividends are then exempt from taxation in Portugal.
If the GV investment gives you returns as dividends then they are not taxed.
(correct me if I am wrong, but) Portugal govt tells you exactly how much taxes you owe the govt and you just pay it. You do not calculate it, like in the US.