Floreo
Lab

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 qq shares takes shares from the front of the queue until qq is reached, possibly across several purchases:

Realized gain=q×Psalelots usedqk×PkCosts\text{Realized gain} = q \times P_{\text{sale}} - \sum_{\text{lots used}} q_k \times P_k - \text{Costs}

where qkq_k is the number of shares taken from purchase lot kk and PkP_k their purchase price.

A simple illustration

A position was built in three purchases:

PurchaseSharesPrice
1 (oldest)50€40
230€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:

Realized gain=70×60(50×40+20×50)=4,2003,000=1,200\text{Realized gain} = 70 \times 60 - (50 \times 40 + 20 \times 50) = 4{,}200 - 3{,}000 = 1{,}200

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:

Realized gain=70×(6042)=1,260\text{Realized gain} = 70 \times (60 - 42) = 1{,}260

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.

Start Demo

The demo opens straight away on a sample portfolio — no account needed.