Average Cost Calculator
Enter your purchases at different times and prices to calculate your average cost basis and your unrealized gain or loss.
Results
Average cost basis
—
Total units
—
Total invested
—
Current value
—
Unrealized gain/loss
—
Average cost = (quantityâ‚ — priceâ‚ + quantityâ‚‚ — priceâ‚‚ + ...) · (quantityâ‚ + quantityâ‚‚ + ...). Unrealized gain is the difference between the current value (total units — current price) and the total amount invested.
Average cost chart
When should you use this calculator?
When you buy stocks, ETFs or cryptocurrencies across several trades at different prices, your average cost basis (also called "average cost") is the single equivalent price that summarizes all your purchases.
How it is calculated
The average cost is calculated as a weighted average by the quantity of each purchase, not as a simple average of the prices: average cost = (quantityâ‚ — priceâ‚ + quantityâ‚‚ — priceâ‚‚ + ...) · (quantityâ‚ + quantityâ‚‚ + ...). The unrealized gain (or loss) is obtained by multiplying the total units by the current price and subtracting the total amount invested across all purchases.
Practical example
A numeric example: buying 5 units at €100, 15 units at €80 and 10 units at €120, the total invested is €2,900 for 30 units, giving a weighted average cost of €96.67. If instead the three prices were simply averaged without weighting by quantity ((100+80+120)/3), the result would be €100 - an incorrect average that doesn't reflect that the largest purchase (15 units) was made at the lowest price. At a current price of €110, the value of the 30 units is €3,300, and the unrealized gain is €400 over the correct average cost of €96.67.
Buying a fixed amount periodically, regardless of the price at the time, is known as "dollar-cost averaging" (DCA). This strategy doesn't guarantee getting the best possible price, but it reduces the risk of investing all your capital at once right at the worst moment, since purchases made at high prices are partly offset by purchases made at low prices.
Common mistakes
A very common mistake is calculating the average cost as a simple average of the purchase prices, without weighting by the quantity bought in each trade: as the example above shows, that mistake can give a result noticeably different from the real average cost, especially when the quantities bought vary a lot between trades. Another frequent mistake is forgetting to add purchase fees to the price per unit, which slightly understates the real cost of each purchase.
Legal and tax context
The average cost is usually also the basis for calculating the taxable result when you sell part of your holdings, although the exact method (FIFO - first purchase sold first -, weighted average cost, or others) varies depending on each country's tax rules. It's worth checking which method applies in your case before calculating the tax result of a partial sale, since it may not exactly match the simple average cost calculated here.
Practical tips
The result of this calculator is a mathematical calculation based on the entered data and doesn't automatically include purchase fees: for a more precise result, you can add the fee paid on each purchase to the price per unit before entering it. This calculator works the same way for shares, ETFs, funds or cryptocurrencies, since the weighted average cost calculation doesn't depend on the type of asset, only on the quantities and prices of each purchase.
Other calculators you may find useful
If you found this calculator useful, you might also want to check out:
Frequently asked questions
What is average cost basis?
It's the single equivalent price that summarizes several purchases made at different prices, calculated as the total amount invested divided by the total number of units bought.
Why does buying at different times change my average cost?
Because each purchase happens at a different price; averaging all purchases weighted by the quantity bought in each one means the result depends on how much you bought and at what price each time.
What is dollar-cost averaging (DCA)?
It's an investment strategy of investing a fixed amount periodically (e.g., every month) instead of investing all your capital at once, aiming to smooth out the effect of purchase-price volatility.
Does this calculator work for both stocks and crypto?
Yes, the average cost calculation is the same regardless of the asset type: stocks, ETFs, funds or cryptocurrencies.
How is unrealized gain or loss calculated?
It's calculated by multiplying your total units by the current price, then subtracting the total amount you invested across all purchases. It's "unrealized" because you haven't sold yet.
Does this calculator account for purchase fees?
Not automatically. For a more precise result, you can add the fee you paid to the per-unit price of each purchase before entering it.
Why is the weighted average cost different from the simple average of prices?
Because the weighted average accounts for how much you bought in each trade, not just at what price. In this guide's example, buying more units at the lowest price (€80) makes the weighted average cost (€96.67) lower than the simple average of the three prices (€100).
Should I include purchase fees in the average cost?
For a more precise result, yes: add the fee paid on each purchase to the price per unit before entering it, since that fee is part of the real acquisition cost of those units.
Is the weighted average cost the same as the FIFO method for tax purposes?
Not necessarily. The weighted average cost uses the average cost of all purchases; the FIFO method treats the first units bought as the first ones sold, each with its own specific purchase price. Your country's tax rules determine which one applies when calculating a capital gain.
What is unrealized gain and how does it differ from realized gain?
Unrealized gain is the difference between the current value of your units and what you invested, calculated using today's market price; it's "unrealized" because you haven't sold yet. It only becomes a realized gain (and a taxable event) at the moment you actually sell.