FIFO capital gains calculator
When you buy the same asset in several lots and later sell part of it, the taxable result is worked out with the FIFO method: the earliest shares you bought are sold first. Enter your trades in chronological order and the calculator gives you the realized gain or loss for each sale, the shares you have left and their average cost.
If you sell in several batches or at different prices, compute the realized result here using the FIFO method (shares bought first are sold first). Enter the operations in chronological order; each sell's result is what goes in the «Resultat» column.
| Operation | Shares | Price | Result | |
|---|---|---|---|---|
| — | ||||
| — |
- Remaining shares
- 0.00
- Remaining avg cost
- 0.00
- Total realized result
- 0.00
What is the FIFO method?
FIFO (First In, First Out) is the rule that decides which shares count as sold when you have buys at different prices. Under FIFO, a sale always consumes the oldest shares you still hold open. It is the method most tax authorities apply to shares, and the most common convention for crypto too.
How is the result calculated?
For each sale, the calculator walks your buys from oldest to newest and takes shares until the sold quantity is covered. The gain or loss is the difference between the sell price and the buy price of each lot consumed. If a sale exceeds the shares available, it warns you. The total realized is the sum of all sales.
Example
You buy 10 shares at €100 and then 10 more at €120. If you sell 15 at €130, FIFO consumes the first 10 (gain 10 × €30 = €300) and then 5 of the second lot (gain 5 × €10 = €50): a realized result of €350. You are left with 5 shares at an average cost of €120.
Frequently asked questions
- What is this calculator for?
- To know how much you gained or lost when you sell part of a position bought at different prices, using the FIFO method. It is the figure you report as a capital gain or loss and the one that goes in the «Result» column of your spreadsheet.
- Does it work for crypto?
- Yes. The calculation is identical for stocks, ETFs or crypto: enter the buys and sells of any asset in order and the calculator applies FIFO the same way.
- What if I only sell part of the position?
- It handles that automatically. It consumes the oldest lots until the sale is covered and shows you the shares you have left open and their average cost, so you can keep tracking.
- Is this the figure I have to declare?
- FIFO is the method tax authorities use for shares, but a tax return can have specifics (fees, withholdings, wash-sale rules). Use this tool as a calculation aid, not as tax advice.
Track your whole portfolio, not just one sale
TrimmTrack computes the FIFO result of every position automatically from your Excel, and adds live P&L, dividends, valuations and projections. Free and no sign-up to try it.
This calculator is a general calculation aid and does not constitute tax advice. Consult a professional for your tax return.