Cost basis calculator
Paste your buys and sells of a coin or share and see the cost basis, realised and unrealised gain under FIFO and average cost, side by side.
One per line, oldest first: buy or sell, quantity, price per unit, and the fee if any. Paste columns from a spreadsheet as they are.
The currency every price is in. The price now gives the unrealised gain; leave it empty to skip.
FIFO: realised gain $5,976.00, cost basis $13,013.00. Average cost: realised gain $4,641.33, cost basis $11,678.33.
ExampleTwo buys and a sell. Paste yours above.
FIFO
Realised gain
+$5,976.00
- Held
- 0.35
- Cost basis
- $13,
013.00 - Unrealised gain
- +$4,
487.00
| Quantity | Cost | Gain |
|---|---|---|
| 0.40 | $12,012.00 | +$5,976.00 |
| Bought on line | Quantity | Cost |
|---|---|---|
| 1 | 0.10 | $3,003.00 |
| 2 | 0.25 | $10,010.00 |
Average cost
Realised gain
+$4,641.33
- Held
- 0.35
- Cost basis
- $11,
678.33 - Unrealised gain
- +$5,
821.67
| Quantity | Cost | Gain |
|---|---|---|
| 0.40 | $13,346.67 | +$4,641.33 |
| Bought on line | Quantity | Cost |
|---|---|---|
| 2 | 0.35 | $11,678.33 |
Nothing leaves your browser: no account, nothing sent, nothing stored.
How it works
Write each buy and sell on its own line, oldest first: buy or sell, the quantity, the price per unit and, if there was one, the fee. Columns copied from a spreadsheet work as they are. The calculator opens with an example: two buys and a sell of part of them.
The calculator works the same trades out two ways, side by side:
- FIFO (first in, first out): a sell takes the oldest units first. When a sell needs only part of a buy, it takes that part of the buy’s cost.
- Average cost: every buy goes into one pool. A sell takes the pool’s cost in proportion to the quantity sold, so each unit sold costs the average. Buys after a sell join the same pool.
Under each method you see what is still held, its cost basis, the realised gain on what you sold and, with a price now, the unrealised gain on what you hold. Below that, each sell with its cost and gain, and the buys still held.
The formula
- Cost of a buy = quantity × price + fee
- Proceeds of a sell = quantity × price − fee
- Gain on a sell = proceeds − cost of the units sold
- FIFO: the cost of the units sold is the cost of the oldest units still held
- Average cost: the cost of the units sold = cost of the pool × quantity sold ÷ quantity in the pool
- Unrealised gain = quantity held × price now − cost basis of what is held
The fees follow the US tax authority’s rules for what you pay and what you receive (IRS Publications 551 and 550); the pool is how the UK’s section 104 holding and Canada’s adjusted cost base work.
Worked examples
FIFO and average cost apart
You buy 1 unit for $100, then 1 for $200, then sell 1 for $300.
- FIFO sells the $100 unit: a gain of $200. You hold the $200 unit.
- Average cost sells a $150 unit: a gain of $150. You hold one unit at $150.
The total is the same in the end. Sell the last unit for $300 and both reach a gain of $300; they differ only in when the gain lands.
A sell that splits a buy, with fees
You buy 2 coins at $10,000 with a $20 fee, then 1 at $13,000 with a $10 fee, then sell 2.5 at $15,000 with a $30 fee.
- You paid $20,020 for the first buy and $13,010 for the second. The sell brings $37,470.
- FIFO: all of the first buy and half of the second, $20,020 + $6,505 = $26,525. The gain is $10,945, and the 0.5 coin left cost $6,505.
- Average cost: the pool cost $33,030 for 3 coins, so 2.5 cost $27,525. The gain is $9,945, and the 0.5 left cost $5,505.
An average that does not divide evenly
You buy 100 units at $1, 50 at $2 and 75 at $1.50: $312.50 for 225 units, $1.3888… each. Selling 100 at $2 costs $138.888…, shown as $138.89, for a gain of $61.11. The calculator keeps every digit until it shows a figure, so the cost of what you sold and what you hold always add up to what you paid.
Questions
What is cost basis?
What you paid for what you hold: the price of each buy plus its fees. Your gain is what you get for it minus that.
Should I use FIFO or average cost?
Use the method where you pay tax. In the US, the oldest units count as sold first (FIFO) unless you name the units you sell. The UK pools shares and coins of one kind at their average cost, with extra rules for buys on the day of a sale and the 30 days after. Canada uses the average cost too (adjusted cost base). If you track for yourself, compare both here.
Do fees count?
Yes. A fee on a buy is part of what you paid, so it adds to the cost basis. A fee on a sell comes off what you got, so it lowers the proceeds. Write each fee in the currency you paid in.
Why does it say I sell more than I hold?
A sell can only take what earlier lines bought. Coins moved in from another wallet, a gift or a buy before your records start all count as buys: add them above the sell with what you paid.
Does it handle small fractions of a coin?
Yes. Quantities and prices keep up to 18 decimal places, and every figure is worked out exactly. Amounts are rounded to the currency only when they are shown: cents for dollars, whole yen for yen.
Is this a tax report?
No. It shows cost basis and gains for a few holdings so you can see where you stand. It does not know your tax rules, holding periods or allowances. For a return, use your broker’s statements or a tax professional.
See where it all is
Every account, card, wallet and cash pile, in every currency, in one place.
Open the web app