What is cost basis?
It is the amount you paid for an investment, used to work out the gain or loss when you sell. For shares bought at different times, it depends on which shares count as sold.
Free calculator
Work out the cost basis of shares you sold and the gain or loss on the sale. Enter each lot you bought with its date, shares and price, then the sale, and the calculator shows the result under two methods side by side: FIFO and average cost.
It also shows which lots FIFO used and the cost basis left on the shares you still hold. The starting values are a fictional example.
| Lot | Shares sold | Cost |
|---|---|---|
| Jan 15, 2025 at $42.00 | 15 | $630.00 |
| Mar 10, 2025 at $50.00 | 5 | $250.00 |
Average price of all lots: $41.60 a share.
Runs in your browser. Nothing you enter is sent or stored.
Cost basis is what you paid for the shares you sold. When you bought at different prices, the answer depends on which shares count as sold. The gain or loss is the sale proceeds minus that cost.
The earliest lots are sold first. The calculator sorts your lots by date, takes shares from the oldest lot until it is used up, then moves to the next. If you leave every date empty, it uses the order you entered.
Every share carries the same cost: the total paid for all lots divided by the total shares. The cost of the shares sold is that average multiplied by the number sold.
| Item | FIFO | Average cost |
|---|---|---|
| Lots held | 15 at $42.00 (Jan 15, 2025), 10 at $50.00 (Mar 10, 2025), 25 at $38.00 (Jun 2, 2025) | 50 shares for $2,080.00, average $41.60 |
| Sale proceeds | 20 × $55.00 = $1,100.00 | $1,100.00 |
| Cost basis of shares sold | 15 × $42.00 + 5 × $50.00 = $880.00 | 20 × $41.60 = $832.00 |
| Gain | $1,100.00 − $880.00 = $220.00 | $1,100.00 − $832.00 = $268.00 |
| Cost basis remaining on 30 shares | $2,080.00 − $880.00 = $1,200.00 | $2,080.00 − $832.00 = $1,248.00 |
These are the calculator's starting values. The two methods give different gains on a partial sale. If you sell every share, both give the same total.
It is the amount you paid for an investment, used to work out the gain or loss when you sell. For shares bought at different times, it depends on which shares count as sold.
FIFO treats your earliest shares as sold first, so the cost comes from your oldest lots. Average cost gives every share the same cost: the total paid divided by the total shares.
Dates decide the FIFO order. Enter a date for every lot, or leave them all empty and the calculator uses the order you entered. Average cost does not need dates.
On a partial sale they assign different costs to the shares sold. Over the whole position the totals match: selling every share gives the same gain under both.
No. The calculation runs in your browser. Nothing you type is sent to Fillfolio or stored.
This calculator gives estimates from the values you enter. It is not tax, legal or investment advice.