Average Cost and Averaging Down, by the Arithmetic explained: formula, worked example and common mistakes
Add up the lots, fold in the fees, and read the average cost and the gain at any price. Free, no sign-up, nothing leaves your browser.
Updated
What averaging does
Buy the same thing several times at several prices and you own a blend. The average cost is the blend in one number: everything spent, divided by everything owned. It is the most useful single figure a position has, because it is also the break-even price — the price at which the position is worth exactly what was paid for it.
The calculator is at /tools/cost-basis/. Type one lot per line, quantity then price, fold in any fees once, and the page reports the total quantity, the total cost and the average cost per unit, with each lot’s own cost and share in a table.
The formula
total cost = Σ (quantity × price) + fees
average cost = total cost ÷ total quantity
market value = current price × total quantity
gain = market value − total cost
gain % = gain ÷ total cost
The fees enter once, not per lot, because the field takes one figure for the position. Charges that vary by lot can be spread into the lot prices instead; the arithmetic does not mind.
A worked example at the calculator’s defaults
Three lots: 10 at 100, 10 at 80 and 20 at 90, no fees, current price 95.
costs: 10 × 100 = 1,000; 10 × 80 = 800; 20 × 90 = 1,800
total = 3,600 over 40 units
average = 3,600 ÷ 40 = 90
value = 95 × 40 = 3,800
gain = 3,800 − 3,600 = 200, which is 5.56% of the cost
Each lot’s share of the quantity is in the table: the 20-unit lot at 90 carries half of it, which is why it moves the average twice as much as either 10-unit lot. Add a tenth lot of 10 at 90 and the average stays exactly 90 — adding at the average changes the size of the position and nothing else.
What fees do
Fees raise the basis and lower the gain by the same amount, which is the honest treatment: money paid to acquire the position is money the position has to earn back. On the defaults, 100 of fees turn the 90 average into 92.5 and the 200 gain into 100 at the same market price. The workings show the fee line separately whenever it is not 0.
What the page does not know
The page computes averages; it does not compute tax. What counts as a cost basis for tax, and which accounting method applies, is a matter for the rules where you are, and this page does not claim to know them. For the same arithmetic from the buying side, see the averaging down calculator; for the yearly return of lots bought at different dates, see the XIRR calculator. Selling only part of a holding? The which lots to sell calculator shows the gain on the same sale under first in first out, last in first out, highest cost, lowest cost and average cost. For many holdings at once, the portfolio XIRR workbench reads a spreadsheet of your transactions and gives back a spreadsheet with the yearly return of each holding.
Frequently asked questions
How does averaging down change the average cost?
A lot below the current average pulls the average down in proportion to its share of the quantity. On the defaults, 40 units average 90; buying 10 more at 80 would take the cost to 4,400 over 50 units, an average of 88. A lot at exactly the average leaves it unchanged, which is a useful check on the arithmetic.
Why are fees added to the cost rather than listed apart?
Because they were spent acquiring the position, so they belong in the basis. The page adds them once to the total cost and the average rises accordingly: 100 of fees on the defaults lift the average from 90 to 92.5. Any gain measured against the basis falls by the same amount.
What is the break-even price of a run of lots?
The average cost, fees included. Below it the position shows a loss if valued at the market price; above it a gain. The gain or loss is linear in the price: every unit of price above the average adds one unit of value per unit held, which is why the gain row and the percentage row move together.
Does the order of the lots matter?
Not to the average. Addition is commutative, so the same lots in any order give the same total cost, quantity and average. The order only affects the table, which lists the lots in the order typed with each one its own cost and share of the quantity.
Is the average cost the same as the tax basis?
Not necessarily. This page works the arithmetic average with fees folded in, which is one convention among several and not a statement about any tax rule. What a tax authority allows as a basis depends on where you are and on the method you are permitted to use, which no calculator on this site claims to know.
This tool shows math, not advice.
Cite this page
Copy this line into a reference list, a report or a spreadsheet note.
Investment Math Calculator. “Average Cost and Averaging Down, by the Arithmetic”. Updated 2026-12-01. https://investmentmathcalculator.com/guides/cost-basis-calculator/
Disclaimer: For education only. These calculators show arithmetic and hypothetical scenarios. They are not investment, tax or legal advice and do not recommend any security or product. Consult a licensed adviser in your country before acting.