How to calculate crypto profit and loss: average cost, FIFO and fees
The crypto profit and loss formula with a hypothetical example: cost basis, fees, average cost vs FIFO, break-even price and the rule used for Portuguese income tax.
Profit or loss on a crypto sale is calculated like this: what you received from the sale (after fees) minus the cost basis of the units sold (price paid plus purchase fees). A positive result is a profit; a negative one is a loss. Until you sell, the gain is only "unrealised" and changes every minute with the price.
The three numbers you need
- Cost basis: what you paid, including fees. Investor.gov, from the US regulator the SEC, defines it as the original price of an asset adjusted for expenses such as commissions.
- Proceeds: what you received from the sale, minus the sale fee.
- Quantity sold: how many units left, and from which purchases.
Formulas:
- Profit/loss = proceeds − cost basis
- Return (%) = profit/loss ÷ cost basis × 100
Hypothetical example: average cost or FIFO?
Imagine (made-up numbers, for illustration only) you bought 0.01 BTC at $50,000 ($500 + $5 fee = $505) and later another 0.01 BTC at $70,000 ($700 + $7 = $707). You spent $1,212 for 0.02 BTC: an average cost of $60,600 per BTC. Then you sell 0.01 BTC at $65,000 and pay a $6.50 fee: you receive $643.50.
| Method | Cost of the 0.01 BTC sold | Result |
|---|---|---|
| Average cost | $606 | +$37.50 (≈ +6.2%) |
| FIFO (first in, first out) | $505 | +$138.50 (≈ +27.4%) |
The same sale gives very different results depending on the method. In Portugal, FIFO applies for income tax: article 43(8)(g) of the Portuguese Personal Income Tax Code says that, for crypto-assets, the units sold are those acquired first, and article 43(9) applies the rule separately at each platform. Other countries use other rules; see crypto taxes by country and estimate the tax in the crypto tax calculator.
Break-even price: how far it must rise for you not to lose
To avoid a loss, the sale value after fees must cover your total cost. With the 0.02 BTC in the example ($1,212 cost) and a hypothetical 1% sale fee: break-even price = 1,212 ÷ (0.02 × 0.99) ≈ $61,212. Add fees, spread and network fees in the all-in cost calculator — we explain network fees in gas and network fees.
Try it with your own numbers
In the profit and loss calculator you enter the coin, the amount and the purchase price (or the purchase date) and see the result at the live price. If you don't remember the price on a given day, look it up in Price on a date. If you buy little by little, read the guide to DCA: your average cost changes with every purchase.
Common pitfalls
- Forgetting fees on purchases, sales and withdrawals.
- Mixing up percentages: a 50% drop needs a 100% rise to get back to where you started (simple maths).
- Crypto-to-crypto swaps: in Portugal, swapping one crypto for another is generally not a taxable event, but you should record the inherited cost.
- Not keeping records: export your platform statements every year.
To track the average cost and result of all your coins in one place, you can create the free Criptos.ai portfolio. General information, not tax or investment advice.
Sources
- Cost Basis — glossary (Investor.gov, U.S. SEC) (2026-11-27)
- Código do IRS, artigo 43.º (mais-valias; n.º 8, alínea g), e n.º 9 — criptoativos) (DGSL) (2026-11-27)
- Lei n.º 24-D/2022 (Orçamento do Estado para 2023) — Diário da República (2022-12-30)
Frequently asked questions
How do you calculate profit on a crypto sale?
Amount received from the sale minus fees, minus the cost basis of the units sold (price paid plus purchase fees).
What is the average cost?
Total spent (including fees) divided by the quantity bought; it changes every time you buy more.
Which method does Portugal use for income tax?
FIFO: the crypto-assets sold are deemed to be those bought first, applied separately at each platform (article 43 of the Personal Income Tax Code).
Is an unrealised gain taxed?
Generally not: in Portugal the gain is taxed when you sell for legal-tender money; until then it is only on paper.
Related guides
- Crypto taxes in Portugal: how to declare crypto in your IRS return
- What is dollar-cost averaging (DCA)? How it works in crypto, pros and cons
- What are gas and network fees in crypto? A simple explanation with examples
- Market order or limit order? How to choose on a crypto exchange
Try these free tools
- Crypto Fear & Greed Index — Today's crypto market sentiment from 0 (extreme fear) to 100 (extreme greed), with daily history since 2018 explained in plain language.
- Crypto scam & hack alerts — The latest crypto hacks, exploits and scams, with real data from DefiLlama and news, explained in plain language for beginners.
- Check a token by its contract address — Paste a token address (Ethereum, BNB Chain, Base, Arbitrum, Polygon or Solana) and see in seconds whether it shows scam signs, hidden taxes and enough liquidity.
- Bitcoin Rainbow Chart — Bitcoin's price since 2010 against its long-term trend, in 9 colour bands. Updated daily and explained in plain language.
Want to follow your coins in one place? Create your free portfolio — wallets, assets and an AI risk check, in a free account. Create a free portfolio
Educational content only, not financial or tax advice. Criptos.ai never recommends buying or selling any asset.