When a portfolio sells a partial position, the question of which lots are sold first is not just an accounting convention — it is a decision that directly affects the investor's tax liability in that tax year. For European retail investors, that decision intersects with national tax rules that are not uniform across the continent: Germany, France, the Netherlands, the UK, and the Nordics each apply different cost basis methods, with different rules for loss harvesting and different treatment of short-term versus long-term gains.
This article is for engineers building portfolio management and rebalancing systems for European markets, and for compliance teams at investment platforms trying to understand their obligations when the system makes lot selection decisions on behalf of investors.
FIFO and HIFO: The Core Distinction
First-In, First-Out (FIFO) assumes that the oldest lots are sold before newer ones. If an investor bought 100 shares in January at €40 and another 100 in June at €55, a sell of 100 shares under FIFO would use the January lot — recognizing a gain against the €40 cost basis.
Highest-In, First-Out (HIFO) instead sells the lot with the highest cost basis first, minimizing the taxable gain (or maximizing the loss offset). Under the same scenario, HIFO would use the June lot, recognizing a gain against the €55 cost basis — a smaller gain, less tax owed this year.
The financial impact of the choice scales with portfolio size and market conditions. A platform managing 30,000 retail portfolios with average portfolio values of €25,000, in a year where equity markets are up 15%, might see the difference between FIFO and HIFO lot selection translate to meaningful variance in capital gains tax reported across the portfolio book. The platform itself does not bear the tax liability — investors do — but the platform bears responsibility for making the selection correctly according to the applicable rules.
Jurisdiction-by-Jurisdiction Rules
Germany operates a FIFO default for shares held in depots through German custodians (Depotgesetz and EStG § 20). German investors cannot freely elect HIFO — the statutory method is FIFO for securities held in the same depot. Loss harvesting in Germany is further constrained by the Verlustverrechnungsbeschränkung under EStG § 20(6): losses from certain instruments (e.g., worthless options) cannot be offset against gains from other categories. The German Abgeltungsteuer (final withholding tax) of 25% plus solidarity surcharge and church tax creates strong incentives for investors to manage their taxable gain positions carefully within the FIFO constraint.
France applies FIFO as the default cost basis method for PEA (Plan d'Épargne en Actions) accounts and standard brokerage accounts (compte-titres ordinaire, CTO). However, the PEA wrapper itself provides capital gains tax exemption after five years of holding the account, which means lot selection inside a PEA primarily affects the wrapper's investment capacity, not the investor's annual tax liability. For CTO accounts, French tax authorities (Direction Générale des Finances Publiques) apply FIFO; HIFO is not a recognized election under French tax law.
The Netherlands applies an entirely different framework. Dutch retail investors are taxed on deemed income from savings and investments under Box 3, not on realised capital gains. The taxable base is the value of assets on 1 January each year, assessed against a deemed return rate. This means that for Dutch investors in standard brokerage accounts, the FIFO versus HIFO distinction is largely irrelevant to their tax liability — what matters is the portfolio value on the reference date, not which lots were sold during the year. ISAs (wrapper structure) and tax-advantaged pension accounts have different rules, but standard brokerage positions are Box 3.
The UK applies a share identification rule under TCGA 1992 s.104: the bed-and-breakfast (B&B) rule, the 30-day rule, and the section 104 pool. UK investors cannot freely apply FIFO or HIFO; instead, same-day and next-30-day acquisitions are matched first against disposals, then the section 104 pooled cost is used. This is materially different from FIFO — the section 104 pool averages the cost basis across all lots, so lot selection in the traditional sense does not apply. A rebalancing engine serving UK investors must implement s.104 pooling correctly, not FIFO or HIFO.
Where HIFO Is Most Valuable
For jurisdictions that permit investor election of cost basis method (notably several Nordic markets and some common law tax systems), HIFO delivers the most value in specific portfolio conditions: large unrealised gains in older lots, recent purchases at higher prices, and rebalancing-driven sells that are mechanically required rather than tax-motivated. In these cases, HIFO defers the gain recognition to a future year, potentially at a lower rate (if the investor's marginal rate falls) or reducing the impact of gain realization in a high-income year.
We are not saying HIFO is always superior to FIFO — for investors anticipating rising tax rates, recognizing gains sooner under FIFO while rates are lower can be preferable. The correct lot selection method depends on the investor's individual tax situation, which is why platforms serving retail investors must be careful about how they present lot selection decisions: the platform can offer HIFO as the default for tax optimization, but should not represent it as always optimal without acknowledging that individual circumstances vary.
Multi-Jurisdiction Portfolios and Consistency Problems
The hardest cases arise when an investor holds positions across multiple European jurisdictions — for example, a German resident investing through a UK-based platform that connects to both Xetra and LSE. The investor is liable for German tax on worldwide income, but the platform's custody chain may use a UK custodian that applies s.104 pooling for UK reporting purposes. The investor's German tax return requires FIFO lot tracking on German-source gains, while the UK custody reporting uses a different method for the same positions.
A rebalancing engine operating in this context must maintain parallel lot ledgers: one that tracks lots according to the applicable national method for tax reporting, and one that tracks the investment cost basis for portfolio performance attribution. These are not the same calculation, and conflating them produces errors in both the tax reporting and the performance reporting.
Automating Lot Selection in Practice
A production lot selection system for a multi-jurisdiction European platform needs to: (1) maintain a lot ledger per position per investor, recording acquisition date, acquisition price, quantity, and currency; (2) apply the correct method based on the investor's tax jurisdiction, which may differ from the exchange on which the security trades; (3) generate audit-trail records for each lot selection decision, including the method applied and the alternatives considered; and (4) handle corporate actions (splits, mergers, spin-offs) that modify lot cost bases.
Corporate actions are an underestimated complexity. A stock split changes the quantity and per-share cost basis of existing lots without changing the total cost basis. An acquisition where shares are exchanged for a combination of cash and new shares requires splitting the lot into a realised-gain component (the cash) and a rolled-over component (the new shares, carrying the original cost basis adjusted for the exchange ratio). These calculations must be applied consistently across the lot ledger before any subsequent sale lot selection, or the tax records will be incorrect.
For platforms at early to mid-scale — say, under 50,000 investors — this complexity is manageable with a well-designed lot ledger database and per-jurisdiction method configuration. The risk increases with scale: at 500,000 investors across 12 jurisdictions, the long tail of edge cases (investors who changed tax residency mid-year, positions transferred in from other custodians with incomplete lot history, corporate actions processed by the custodian on a different timeline than the platform's records) becomes a meaningful operational burden. Platforms that defer building proper lot management infrastructure until they are at scale find it significantly harder to retrofit.