If you have to file taxes in the US, and you had a big capital gain this year, you are in for a bit of a surprise. As part of the Obama-care deal, there’s a new tax called the “Net Investment Income Tax”. This is a 3.8% tax on unearned (eg interest, dividends, capital gains) over a certain threshold depending on your income.
The particularly nasty thing about this tax is that you cannot reduce it via foreign tax credits (it gets added to your taxes after the credits are applied), so you may face a situation where you are taxed twice.
However, all is not lost. If you are a Spanish tax resident, you may be able to apply the taxes you pay to the US as a tax credit in Spain.
The general rule for Spain is that your foreign tax credit is equal to the lesser of:
1) Taxes paid on foreign income because of a tax similar to IRPF
2) The Spanish taxes you would owe on the fraction of your income that is foreign.
What this means is that you should definitely not hold your investments in Spain, otherwise you will have no foreign income, and thus can take no credits. Of course, this only works if your Spanish tax rate is higher than the US one would be.
Unfortunately the Spanish tax law forces you to apply the income and savings baskets separately, so in most cases you’re screwed, except for short term capital gains, where as of 2013 you integrate short term capital gains into your general income (and thus taxed up to 42%).