Guide

How to Calculate Your Cost Basis for Investments

Cost basis is the number that determines your taxable gain when you sell. Most investors don't track it properly — and it costs them at tax time.

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.

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:

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:

MethodCost basis usedGain on 10 shares at €100Best when...
FIFO€50/share€500Your oldest shares have the lowest basis and you want simplicity
LIFO€80/share€200Recent purchases have high basis and you want to minimize current gains
Average cost€65/share€350You 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:

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:

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:

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 →
Cost basisFIFOLIFO Capital gainsTax lotsInvestment tax