Spain matches every sale to the oldest purchase lots first (FIFO, art. 37.2 LIRPF). Selling 15 units at €180 bought as 10 @ €100 + 10 @ €150 with €20 total costs realizes ≈€933 of gain — ≈€177 of savings tax in the 19% bracket.Enter each purchase lot (date, quantity, unit price, expenses) and the sale. You get the lot-by-lot FIFO matching table, the gain or loss net of expenses, the lots still open, and an estimate across the 2025 savings brackets (19–30%). Informational draft, not tax advice.
| Lot | Buy date | Units | Cost/u | Cost basis | Proceeds | Gain | Days |
|---|---|---|---|---|---|---|---|
| Lot 1 | 2023-01-15 | 10 | €100.50 | €1,005.00 | €1,793.33 | +€788.33 | 877 |
| Lot 2 | 2024-03-10 | 5 | €150.50 | €752.50 | €896.67 | +€144.17 | 457 |
| Total | 15 | €1,757.50 | €2,690.00 | +€932.50 |
| Lot | Buy date | Units | Cost/u | Cost basis |
|---|---|---|---|---|
| Lot 2 | 2024-03-10 | 5 | €150.50 | €752.50 |
| Bracket | Rate | Taxable | Tax |
|---|---|---|---|
| €0 – €6,000 | 19% | €932.50 | €177.18 |
| €6,000 – €50,000 | 21% | — | — |
| €50,000 – €200,000 | 23% | — | — |
| €200,000 – €300,000 | 27% | — | — |
| €300,000 and above | 30% | — | — |
| Total | 19.0% | €932.50 | €177.18 |
Live demo — this free tool runs the exact same FIFO engine as the CompoundVision Pro tax cockpit.
Informational draft — not tax advice. Savings-base brackets for income year 2025 (art. 66 LIRPF; 30% top bracket per Ley 7/2024), filed in 2026. Assumes the gain is your only savings-base income; loss compensation (arts. 47–49 LIRPF) and the two-month repurchase rule (art. 33.5) are not modelled. All calculations run in your browser — nothing is uploaded.
Spain-style FIFO capital gains calculator
Enter each purchase lot — date, quantity, unit price and expenses — plus the sale, and the calculator consumes the oldest lots first, exactly as Spanish law mandates for homogeneous securities (art. 37.2 LIRPF). You get the per-lot matching table, the total gain or loss net of expenses, the lots you still hold, and an estimate across the 2025 savings-base brackets (19% to 6,000 €, 21% to 50,000 €, 23% to 200,000 €, 27% to 300,000 €, 30% above).
How to compute FIFO capital gains for a sale
- Add one row per purchase lot: acquisition date, units bought, unit price and the expenses inherent to that purchase.
- Enter the sale: date, units sold, sale price per unit and the costs of the sale you paid.
- Read the matching table — the sale consumes the oldest lots first; each row shows units taken, cost basis, net proceeds and gain.
- Check the estimated tax across the 2025 savings brackets (19–30%) and the lots that remain open for future sales.
Common use cases
- Selling part of an ETF or fund position accumulated with monthly purchases and finding which lots Hacienda considers sold.
- Comparing the FIFO gain against the average-cost figure your broker statement shows before filing the Renta.
- Estimating the IRPF hit of a crypto sale where coins were bought at very different prices across 2021–2025.
- Preparing a draft for your accountant with per-lot cost basis, holding days and remaining open lots.
Frequently asked questions
Why FIFO and not average cost?
For homogeneous securities (same share, fund or coin), Spanish law deems the units sold to be the first ones acquired (art. 37.2 LIRPF). Broker statements often show average cost, which can differ substantially from the FIFO gain you must declare.
Which expenses count?
Expenses and taxes inherent to the purchase increase the acquisition value, and those of the sale paid by you reduce the transmission value (art. 35 LIRPF). Typical examples: broker commissions, market fees, transfer taxes. Financing costs do not count.
What if the result is a loss?
A capital loss produces no savings-base tax. It can offset capital gains and, with limits, other savings income over up to four years (arts. 47–49 LIRPF) — this draft does not model offsetting, and the two-month repurchase rule (art. 33.5) can defer the loss.
Is this tax advice? Is my data uploaded?
No and no. It is an informational draft using the 2025 savings-base brackets — always confirm with a professional before filing. Everything runs locally in your browser; lots, prices and results are never sent anywhere.
Why FIFO order changes your tax bill
Most brokers display average cost, but when you sell shares, fund units or crypto bought in several batches, Spain identifies the units sold as the OLDEST ones first. If your early lots were cheap, FIFO front-loads the gain — and the tax — compared with the average-cost figure on your broker statement. Purchase expenses raise the acquisition value and sale expenses cut the transmission value (art. 35 LIRPF), so commissions belong in the math, not in a footnote. This free tool is a live demo of the same FIFO engine that powers the CompoundVision Pro tax cockpit.
- True first-in-first-out lot matching (Spain-style, art. 37.2 LIRPF)
- Unlimited purchase lots with date, quantity, price and expenses
- Purchase expenses raise basis; sale expenses cut proceeds (art. 35 LIRPF)
- Per-lot gain/loss, holding days and remaining open lots
- 2025 savings-base bracket estimate: 19% / 21% / 23% / 27% / 30%
- Loss detection with honest 'no tax due, offsetting not modelled' note
- Runs entirely in your browser — lots and amounts never leave your device
Free. No signup. Inputs stay in your browser. Ads via AdSense (consent required).
By Marco B. ·