When you sell an investment, the tax you owe isn't calculated on what you received — it's calculated on your gain. And your gain is the difference between your selling price and your cost basis. Get the cost basis wrong, and you'll either overpay taxes or underpay them (and risk penalties).
For investors who buy the same stock or fund multiple times at different prices — which is almost everyone who invests regularly — calculating cost basis correctly requires understanding tax lot accounting methods. This guide explains each method clearly, with real numbers.
What is cost basis?
Your cost basis for an investment is generally the total amount you paid for it, including any transaction fees. For shares purchased at different prices over time, you have a separate tax lot for each purchase — and when you sell, you need to specify which lots you're selling, because it directly affects your taxable gain.
⚠️ Important: This article explains the general mechanics of cost basis calculation. Tax rules vary significantly by country and personal situation. Always consult a qualified tax advisor before making decisions based on tax lot strategy.
The three main cost basis methods
FIFO — First In, First Out
FIFO assumes that the shares you bought first are the shares you sell first. It's the default method in many countries and for most brokers if you don't specify otherwise.
Example: You bought 10 shares of Company X at €50 in January, then 10 more at €80 in June. You now sell 10 shares at €100.
- FIFO says you sold the January shares (cost basis €50)
- Your gain = €100 − €50 = €50 per share = €500 total
LIFO — Last In, First Out
LIFO assumes the most recently purchased shares are sold first. This can reduce your current tax bill if your newer shares have a higher cost basis — but it may not be available in all jurisdictions.
Same example with LIFO:
- LIFO says you sold the June shares (cost basis €80)
- Your gain = €100 − €80 = €20 per share = €200 total
Average Cost
Average cost calculates the mean price paid per share across all your purchases. It's simple, consistent, and widely used for mutual funds.
Same example with average cost:
- Average cost = (10×€50 + 10×€80) ÷ 20 = €65 per share
- Your gain = €100 − €65 = €35 per share = €350 total
| Method | Cost basis used | Gain on 10 shares at €100 | Best when... |
|---|---|---|---|
| FIFO | €50/share | €500 | Your oldest shares have the lowest basis and you want simplicity |
| LIFO | €80/share | €200 | Recent purchases have high basis and you want to minimize current gains |
| Average cost | €65/share | €350 | You want consistency across all lots |
Specific lot identification
Beyond the three methods above, many brokers allow you to choose exactly which tax lots to sell — this is called specific identification. It gives you the most control over your tax outcome and lets you optimize lot by lot.
Common uses of specific lot identification:
- Tax-loss harvesting: Sell the lots with losses to offset gains elsewhere in your portfolio
- Holding period management: Sell lots that qualify for long-term capital gains rates (typically held 12+ months) rather than short-term rates
- Minimizing current year taxes: Sell the highest-basis lots to minimize current year reportable gain
Why consistent tracking matters more than the method you choose
The method you choose is less important than your commitment to tracking every purchase consistently. Here's what tends to go wrong:
- Investors forget they reinvested dividends — each dividend reinvestment creates a new tax lot with its own basis and holding period
- Corporate actions (splits, spinoffs, mergers) can adjust your basis and aren't always reflected automatically in brokerage statements
- Investors who change brokers lose their lot history and have to reconstruct it manually
- Crypto investors often have dozens of small purchases across multiple wallets and exchanges — without a tracking system, calculating basis becomes extremely difficult
Cost basis for crypto: extra complexity
Cryptocurrency adds a layer of complexity because every trade — including swapping one token for another — is typically a taxable event in most jurisdictions. Your cost basis for crypto includes:
- The purchase price in your base currency at the time of acquisition
- Transaction fees paid to acquire the asset
- The fair market value at time of receipt for mined or staked rewards
Given the frequency of crypto transactions for active traders, maintaining accurate cost basis records requires a system — not a spreadsheet.
Tracking it in WealthFlow
WealthFlow stores every purchase as a separate transaction with its date, price, quantity, and currency. You can configure your preferred calculation method (FIFO or LIFO) in your account settings. The system then uses that method consistently across all calculations, giving you a clean basis for each position and accurate gain/loss reporting at any point in time.
Never lose track of your cost basis again
WealthFlow logs every transaction with date, price and quantity — and supports both FIFO and LIFO calculation methods across all your asset types.
Start for free →