This crypto cost basis calculator shows how much gain or loss you report when you sell part of your coins, and what cost basis stays on the coins you keep. Enter your buys and sales, with fees, and it works out the result with FIFO and with weighted average cost side by side, plus LIFO and HIFO for comparison, and shows which lots each sale used. It does not replace the crypto profit calculator, which is for one buy and one sale: use this one when you bought at several prices.
FIFO, average cost, LIFO and HIFO in plain words
When you bought the same coin several times at different prices and then sell only part of it, you have to decide which coins you sold. The cost of those coins is your cost basis, and the gain is the sale price minus that cost. The four common methods:
| Method | Which coins you sell | What it tends to do when prices rose |
|---|---|---|
| FIFO (first in, first out) | The oldest coins first | Uses the cheapest, oldest coins, so it shows a bigger gain now |
| Weighted average cost | A slice of every buy, at the average price of the pool | A middle result; the average only changes when you buy |
| LIFO (last in, first out) | The newest coins first | Uses recent, pricier coins, so it shows a smaller gain now |
| HIFO (highest in, first out) | The most expensive coins first | Shows the smallest gain now, but only where you are allowed to pick units |
Over the whole life of your coins, every method adds up to the same total gain. What changes is the year the gain shows up. A method that shows less gain this year leaves a lower cost basis on the coins you keep, so the gain appears when you sell them.
Worked example
You bought bitcoin three times and sold 0.6 BTC in November 2025. Fees are added to the cost of each buy and taken off the sale proceeds.
- Buys: 0.5 BTC at $40,000 + $20 fee = $20,020; 0.3 BTC at $65,000 + $15 = $19,515; 0.4 BTC at $95,000 + $25 = $38,025. Total: 1.2 BTC for $77,560.
- Sale: 0.6 BTC at $90,000 = $54,000, minus a $30 fee = $53,970 of proceeds.
- FIFO: the whole first lot ($20,020) plus 0.1 BTC of the second at $65,050 per coin ($6,505) = $26,525 of cost. Gain: $53,970 − $26,525 = $27,445. Cost basis left on the 0.6 BTC you keep: $51,035.
- Average cost: $77,560 ÷ 1.2 = $64,633.33 per coin. 0.6 BTC costs $38,780. Gain: $15,190. Cost basis left: $38,780.
- LIFO and HIFO: the 0.4 BTC bought at $95,000 plus 0.2 BTC of the second lot = $51,035 of cost. Gain: $2,935.
The method can move thousands of dollars of gain from one tax year to another. You usually cannot choose freely: your country sets the method or expects you to keep the same one every year, so check the rule before you file.
Which method does your country use?
| Country | Rule for crypto of the same type | Official source |
|---|---|---|
| United States | FIFO by default, wallet by wallet or account by account; or the specific units you identify no later than the sale | IRS digital asset FAQ |
| United Kingdom | One pool per token (section 104 pool), at the pooled average cost; same-day and 30-day buys are matched first | HMRC Cryptoassets Manual |
| Spain | FIFO: the units bought first are the ones sold | AEAT Renta 2025 manual |
| Brazil | No rule written only for crypto; weighted average cost (custo médio) is the method used in practice | Receita Federal |
| Mexico | Proven acquisition cost, updated for inflation; the law does not set which units leave first | Income Tax Law, art. 121 |
| Colombia | Tax cost starts from the purchase price; DIAN has not set FIFO or average cost | DIAN concept 18075 of 2023 |
| Nigeria | Gain = proceeds minus acquisition and selling costs; no matching method set for crypto units | Nigeria Tax Act 2025, ss. 34 and 39 to 41 |
Where the law does not fix a method, use one, keep it every year and keep the records that back it up. Country guides with rates, deadlines and how to declare: Brazil, Mexico, Colombia and Nigeria. The US and the UK are covered in our crypto tax guide.
How to enter your trades
- One buy or sale per line: date, quantity, price per coin and fee, separated by spaces or semicolons. Dates as 2025-03-31.
- Use the same currency for every amount, the one you pay tax in. If you bought with another currency, convert each trade at the rate of that day.
- One coin per calculation: do not mix bitcoin and ether. Each coin has its own pool or queue.
- A swap of one coin for another usually counts as a sale of the coin you gave up at its market value (in the US and the UK, for example). Enter it as a sale.
- Up to 10 buys and 10 sales. For a full year of trades, use the spreadsheet or crypto tax software.
Bought once and sold once? The simple calculator also adds tax on the gain.
Open the crypto profit calculatorFrequently asked questions
Which is better for taxes, FIFO or average cost?
Neither saves tax over time: both add up to the same total gain once you have sold everything. When prices have risen, FIFO shows more gain now and average cost shows less. In most countries the method is set by law or practice, so the choice is usually not yours.
Can I use average cost for crypto in the US?
The IRS rules for digital assets use FIFO by default, or the specific units you identify no later than the sale. Average cost is not one of the options the IRS describes for crypto, so use FIFO or specific identification.
What is the 30-day rule in the UK?
If you sell tokens and buy the same type within 30 days after the sale, HMRC matches the sale with that new purchase first, not with your pool. Same-day purchases come first of all. The calculator warns you when this may apply but does not apply it.
Do fees count in the cost basis?
Generally yes. Fees you pay to buy are added to the cost, and fees you pay to sell reduce the proceeds. Keep the exchange statements that show them.
Can I change method from one year to the next?
Usually not freely. Tax authorities expect the method set by law, or one method used consistently. Changing it to lower one year’s tax can be challenged.
Related guides
CryptoCrypto tax guideHow crypto is taxed in the US and the UK.
CryptoCrypto tax software comparedTools that track your cost basis across exchanges.
CryptoCrypto profit calculatorProfit or loss after fees and tax for one trade.
InvestTax calendar 2027Filing and payment dates by country.Sources
- IRS: Frequently asked questions on digital asset transactions
- HMRC: Cryptoassets Manual, CRYPTO22200 (pooling)
- Agencia Tributaria: Manual práctico de Renta 2025, monedas virtuales
- Receita Federal: Criptoativos
- Cámara de Diputados (Mexico): Ley del Impuesto sobre la Renta
- DIAN: Concepto 18075 de 2023 (criptoactivos)
Rules reviewed on 1 December 2026. Crypto is high-risk; you can lose all the money you put in.
For information only: this is not tax or financial advice. Tax rules change and depend on your circumstances, so check with a qualified tax or financial adviser before acting.