Specialized Guide

Capital gains across brokers: the FIFO Hacienda actually uses

If you buy on DeGiro and sell on IBKR the same ISIN, Hacienda uses one FIFO (art. 37.2). Worked example in euros.

The ideas in this guide are there to explain how Hacienda applies FIFO when the same security sits at several brokers. With Aitax you upload the documents: the AI takes care of the heavy lifting. You check that the figures are right. If a question comes up, you ask the specialised AI, trained on the law as it stands.

If you buy the same ISIN at DeGiro and sell it at Interactive Brokers, Hacienda does not use each broker’s FIFO. It uses a single intake order for homogeneous securities, even if the shares sit in different accounts. That is article 37.2 of the Spanish Personal Income Tax Act. If you skip it, a single-broker certificate is a lie.

One sentence: the shares you bought first (DeGiro at €50) are the ones that leave when you sell at IBKR at €90, even if IBKR “thinks” you sold its €80 lot. The Spanish gain is higher.

What “homogeneous” means

The same class of security: in practice the same ISIN (shares or equivalent ETFs). You do not mix Telefónica with an S&P ETF. You do mix the same listed share bought at two brokers.

Spanish FIFO is not the broker app’s method (often average cost, or FIFO per account). It is not a US 1099 FIFO and not a global tracker’s lot.

Worked example (buy at A, sell at B)

DateBrokerEventPriceShares
10 MarDeGiroBuy€5010
20 JunIBKRBuy€8010
15 NovIBKRSell€9010

IBKR FIFO (its account only): cost €80 × 10 = €800. Sale €900. Gain €100.

Hacienda FIFO (art. 37.2): March shares leave first. Cost €50 × 10 = €500. Sale €900. Gain €400.

The 10 IBKR shares stay in the book at €80 cost. If you sell them next year at €70, you realise a loss against that lot — the opposite of the “profit” IBKR showed in November.

If you traded in USD, each leg converts at the ECB rate on the trade date, not “today” and not your app’s FX.

Why this is the actual moat

Anyone can put “multi-broker FIFO” in a title. The work is sorting every trade in that ISIN on one timeline, ignoring which account held it, without breaking fund switches (art. 94) or the anti-abuse rule on losses (art. 33.5: 2 months listed / 12 unlisted).

A generalist advisor rarely rebuilds this by hand. A one-shot script does not show the lot. A payroll tax app asks for the certificate: the certificate is already wrong if it only sees one broker.

What to do with statements

  1. Export the full history from each broker (not only this year’s tax PDF).
  2. Do not drop old buys: FIFO needs the inbound stock.
  3. Internal transfers between your accounts are not sales.
  4. Keep dividends separate (savings income, not capital gains).

Aitax imports IBKR, DeGiro, XTB, Trading 212, Revolut and others, merges the ISIN and shows the lot Hacienda would use. You review; it is not auto-filing with the AEAT.

720 and 721

Modelo 720 reports year-end foreign balances. It does not compute this gain. 721 is crypto custodied abroad. Share sales belong on Renta, with this FIFO.

FAQ

Does this apply if both brokers are Spanish?
Yes. Art. 37.2 does not require a foreign broker. Several Spanish banks with the same fund also consolidate.

What if the broker uses average cost?
Irrelevant. You file legal FIFO.

Can I “choose” to sell the IBKR lot?
Not for homogeneous listed securities. The order is statutory.

What if I already filed last year wrong?
Amending is usually cheaper than waiting for a check. See the guide on misreporting stocks.


Compute FIFO across your brokers →

Ready to declare your investments?

Upload your broker reports and Aitax prepares your Renta.

Prepare my Renta