What is the FIFO method for calculating gains?
FIFO — first in, first out — is a method for deciding which shares a sale comes from, when a position was built with several purchases at different prices. Under FIFO, every sale is matched to the oldest shares still held. The realized gain is then the selling price minus the purchase price of those oldest shares.
The method matters because it changes the size of each realized gain, and therefore the tax due in a given year. German tax rules, for example, prescribe FIFO for securities held in a normal custody account.
How it works
The purchases form a queue, oldest first. A sale of shares takes shares from the front of the queue until is reached, possibly across several purchases:
where is the number of shares taken from purchase lot and their purchase price.
A simple illustration
A position was built in three purchases:
| Purchase | Shares | Price |
|---|---|---|
| 1 (oldest) | 50 | €40 |
| 2 | 30 | €50 |
| 3 (newest) | 20 | €35 |
70 shares are then sold at €60. Under FIFO, the sale takes all 50 shares of purchase 1 and 20 of purchase 2:
The 30 shares that remain are 10 from purchase 2 at €50 and 20 from purchase 3 at €35.
With the average cost method instead, every share carries the average purchase price of €42, and the realized gain is:
Why it matters
- Taxes. In steadily rising markets the oldest shares are usually the cheapest, so FIFO tends to realize larger gains earlier. In this example it realizes less, because the oldest shares were not the cheapest.
- Reported performance. The split of a position's gain into realized and unrealized depends on the method, although the total does not.
- Consistency. A broker's tax report and a portfolio tracker's figures can only be compared if both use the same method.
Things to keep in mind
- FIFO usually applies per custody account. Shares of the same security held with two brokers form two separate queues.
- Transfers must carry the purchase history. Without the original dates and prices, the queue cannot be rebuilt correctly.
- The total gain is the same under every method over the life of a position; only its timing differs.
Related topics
See these numbers for your own portfolio
Floreo works out every figure on this page from your own holdings — returns, risk, allocation, currencies — and the assistant explains them the way this page does. Import from your broker, or try it on the sample portfolio first.
The demo opens straight away on a sample portfolio — no account needed.

