Investment income and capital gainsArticle 3 of 12 · 3 min read
How capital gains on shares and funds are calculated in Spain
How to work out your taxable gain or loss when you sell shares, funds or ETFs as a Spanish tax resident: which units count as sold first, which costs you can deduct, and how to convert foreign currencies into euros.
Key rules
- FIFO: The oldest units you bought are treated as sold first, across all your brokers.
- Deductible costs: Documented purchase and sale commissions and taxes count; ongoing custody fees do not.
- Euro conversion: Convert each purchase and sale at the exchange rate on its own date.
- Currency effect: Currency movements are included in your gain or loss, because it is calculated in euros.
The basic calculation
Your gain or loss on each sale is the sale value minus the purchase value. You work it out separately for each security, in euros.
Which units count as sold first
The first units you bought are treated as the first ones sold. This is called FIFO (first in, first out). It applies to "valores homogéneos": securities of the same issuer that give identical rights. In practice, that means the same ISIN code.
FIFO covers your whole holding of that security, whatever the broker or account. If you bought the same fund at two brokers, pool the purchases and sell them in order of purchase date.
Example: you buy 10 units in January and 10 more in June. You then sell 10. The sale is matched with the January units and their cost.
Which costs you can deduct
Purchase value is the price you paid plus the costs and taxes you paid as buyer. That includes broker commissions and stamp or transaction taxes.
Sale value is the sale price minus the costs and taxes you paid as seller, such as the sale commission.
- Keep documents for every cost. You can only deduct costs you can show.
- Ongoing custody or account maintenance fees cannot be deducted from the gain.
- For listed securities, the sale value is the actual price, but never less than the listed price.
Converting foreign currencies into euros
Convert each transaction at the exchange rate on its own date. Convert purchases at the rate on the purchase date, and sales at the rate on the sale date.
No single rate source is mandated. The ECB euro reference rate for that day is the commonly accepted choice. Euro figures supplied by your broker are also generally accepted. Keep a note of the source you used.
Because the gain is calculated in euros, currency movements count. You can have a gain in euros even if the price in dollars did not change, or a loss even if it rose.
Losses and repurchases
A loss is not counted if you bought the same security within two months before or after the sale for listed securities, or one year for unlisted ones. The rules for this are covered elsewhere in this guide. Check it before you sell at a loss to cut your tax bill.
The questions below cover brokers, fees and exchange rates.
Frequently asked questions
Does FIFO apply separately at each broker?
No, FIFO applies to your whole holding of the same security, whatever the broker or account. Shares of the same ISIN bought at several brokers are pooled and sold in order of purchase date. So the oldest purchase is treated as sold first, even if it sits at a different broker.
Can I deduct my broker's custody fees from a gain?
No, ongoing custody or account maintenance fees are not deductible against the gain. Purchase commissions and taxes add to your acquisition cost, and sale commissions reduce your sale value. Keep documents for every cost you claim.
Which exchange rate should I use for a foreign-currency sale?
Use the euro rate on the day of each transaction, so the purchase-date rate for purchases and the sale-date rate for sales.
Does currency movement count in my gain?
Yes, the gain is calculated in euros, so currency effects are included in your gain or loss. A sale can show a euro gain even if the price in the foreign currency fell.
More in Investment income and capital gains
- How Spain taxes interest and dividends (savings income)
- Foreign dividends: Spanish tax plus tax already withheld abroad
- Cost basis and exchange rates for investments bought before you moved
- Funds versus ETFs: why Spanish tax treatment differs
- Accumulating or distributing funds: when Spain taxes reinvested income
- Using investment losses against gains in Spain
- Spanish broker or foreign broker: who reports and who withholds
- Insurance-based savings and unit-linked policies in Spain (seguros de ahorro)
- US citizens in Spain: PFIC rules and dual investment reporting
- Owning a foreign company: how its profits and dividends are taxed
- Do ISAs, Roth accounts, TFSAs and trusts keep their tax benefits?
← Back to Investment income and capital gains · Find your city
Need certainty before you act?
For important relocation decisions, speak with a qualified human specialist.
Always verify important information with the relevant official authority or a qualified adviser before acting. This website uses large language models together with various public data sources, official government documents and other established sources. Due to the amount of data on this website, some information might be wrong. Information may also be incomplete or outdated.