Each purchase lot, its cost (units × price), and how the lots combine into a weighted average cost per unit, from the values you entered. Lots with zero units are omitted. The average is total cost divided by total units, not a plain average of the prices.
Lot
Units
Price/unit
Lot cost
Lot 1
100
20
2,000
Lot 2
50
30
1,500
Total
150
3,500
Weighted average cost/unit
23.33
Estimates only — not financial, tax, or professional advice.
Calculated in your browser — the numbers you enter are never sent to our servers.
What it calculates: Average Cost per Unit, Total Units, Total Cost.
The lot sizes decide the answer, not the number of lots
Averaging the three prices treats a ten-unit buy and a thousand-unit buy as equals, which is wrong by a wide margin. The correct figure is the total amount spent divided by the total units held, so each price is weighted by how much you bought at it.
average cost = total cost / total units
The gap between the two methods is largest exactly where it matters: someone who bought a small position early and added heavily later has a true average close to the later price, while the naive average sits misleadingly between them.
The method is set by the rules, not by preference
Mutual funds in many jurisdictions require average cost. Individual shares are commonly matched first-in-first-out unless you specifically identify the lots being sold, and some systems permit a choice that must then be applied consistently.
It is worth establishing which applies before computing anything, because the methods give materially different gains on the same sale. Choosing the method that suits the outcome, rather than the one the rules specify, is the error to avoid here.
A partial sale leaves the average cost unchanged
Under averaging, selling some units does not change the cost per unit of the ones you keep. The remaining holding carries the same blended basis, and the gain on the sale is measured against that figure.
A later purchase does change it. Adding units at a higher price raises the blended cost, which reduces the gain on future sales — the mechanical reason averaging behaves so differently from first-in-first-out in a rising market.
What this covers and where it stops
The tool takes up to three lots of a single security. A holding built from more purchases can still be handled by consolidating groups of buys into a single lot entry with the combined units and their own blended price, which is arithmetically identical.
Transaction costs are not included here — add them through the cost basis calculator first if you want them in the figure — and corporate actions such as splits and bonus issues must be applied to the unit counts before averaging, not after.
Frequently Asked Questions
How do I calculate average cost basis?
Multiply the units by the price in each lot, add those costs for the total cost, add the units for the total units, then divide total cost by total units. Lots of 100 at 20 and 50 at 30 average to 3,500 over 150, or 23.33 per unit.
Why not just average the prices?
A simple average of the prices ignores how many units you bought at each price. The correct figure is a weighted average that gives more influence to larger lots, which is what this calculator computes.
When is average cost used?
It is a common method for shares, mutual fund units, and sometimes crypto, especially where many purchases occur over time. Some jurisdictions require or default to it, while others let you choose, so confirm the rule.
How does it differ from FIFO?
FIFO assumes the earliest units are sold first, using their original prices, while averaging blends all purchases into one cost. The two can produce different gains, particularly when prices have moved a lot.
Can I include buying fees in the price?
Yes, if you fold the acquisition costs into each lot’s price per unit, the average basis will reflect them. Alternatively, track fees separately, but be consistent across lots.
What if I have more than three lots?
Combine some lots before entering them, or compute the total cost and total units yourself and divide. The method is the same regardless of how many purchases you have.
Sources & References
Figures on this page are checked against primary, authoritative sources. Links open in a new tab.
Tax rules vary by country, state, tax year, filing status, income type, deductions, and exemptions. This calculator is educational and uses the values you enter. Always verify final tax treatment with official sources or a qualified tax professional.
Published the calculator with its formula, worked example, assumptions, limitations and a bespoke guide, and added an automated formula test suite covering it.
Tested the unit-weighted average across three purchase lots against a hand-computed total cost over total units.
Tested that the weighted average always falls between the cheapest and dearest lot price, and equals it when only one lot has units.
Frequently Asked Questions now show on the page: 6 answers, checked in a page-by-page audit.
What the calculation assumes and where it stops now show on the page.
Add this calculator to your site
Responsive embed — and private: nothing your visitors type leaves their browser.