How this cost basis figure is worked out
Each row holds one purchase: how many shares it bought, and the price paid for each of them. The page turns every row into the money that purchase cost, adds those amounts together, and divides the total by every share the rows bought. One division, and what comes out is the cost basis per share for the position those rows describe.
Cost basis per share = (q1×p1 + q2×p2 + … + qn×pn) ÷ (q1 + q2 + … + qn)
where q is the share count on a row and p is the price per share on that same row. The top half of the fraction is the total cost and the bottom half is the total shares, so both of the other two figures on this page come out of the same sum, not from a second calculation.
Worked example: 10 shares at $25.55, 5 shares at $25.60 and 3 shares at $25.65. The rows cost 255.50, 128.00 and 76.95, which adds up to a total cost of 460.45 across 10 + 5 + 3 = 18 shares. 460.45 ÷ 18 gives a cost basis of 25.5805 per share. Type those three rows in and the page prints the same figures underneath, one line per row, so you can check each one against the numbers you typed.
Why this is called an average cost basis
Average here is the weighted kind, not the plain one. A row's price counts for as many shares as that row bought, so one large purchase pulls the figure further than a small one at a different price. Take 100 shares at $50 and 10 shares at $60: what comes back is 50.909 a share, because the 5,600.00 that went in is spread over all 110 shares. The plain average of the two prices would be 55, and it would describe nothing that happened — not one share was bought at 55.
The other half of the name is basis. Basis is what the shares cost you, so an average cost basis is that total cost spread evenly across the shares, and the page reaches it in a single division. There is no lot to pick and no order to put the buys in: the same rows typed in any order come back with the same figure.
What the name does not tell you is where the method stands on a tax return. Average basis is one of three ways a sale can be matched against shares, and it is the narrow one: it is available for mutual fund shares and for shares held in a dividend reinvestment plan, while ordinary stock in a brokerage account is matched by first in, first out or by naming the shares you sold. The home page's Cost basis methods section sets all three out with the IRS wording behind each one. What comes back here is the average of the rows you typed, and this page makes no claim to be the figure a particular tax return should carry.
Decimal places, and the way they are taken here
Four statements, and they cover every figure on the page.
- Cost basis per share: at most four decimals. Anything past the fourth decimal is thrown away. The example above divides out to 25.58055 recurring, and the page shows 25.5805, not 25.5806.
- Total shares: at most four decimals, under the same rule. A share count may carry decimals, so 10.5 shares is a figure this page takes as readily as 10. A count that comes out whole shows without trailing zeros.
- Money: two decimals, also by throwing away the rest. A total of 460.449 would be shown as 460.44, never as 460.45.
- Each row's own cost: two decimals, the same way. The total cost is the exact rows added up and then cut at two decimals, so with prices of two decimals or fewer the rows you read add up to the total you read, to the cent.
So this page truncates rather than rounds. Nothing is ever rounded up, which means a figure here is never larger than the number the rows actually produce. Where a figure does get rounded, the last digit lands one step higher than the one shown here, and the gap between the two is smaller than a cent per share. If you are putting the figure somewhere that works in whole cents, round the printed number yourself at the end, and write down which way you took that last digit, because the two ways do not always land on the same number.
How many places should a cost basis be carried to? Nothing in this page's sources fixes a number: four decimals is simply enough that multiplying the per-share figure back by the share count stays within a cent of the total, and it is the number kept everywhere on this site. Treat the choice of four as this page's own, stated so that you can take a different one on purpose instead of by accident. That statement itself is the part most cost basis calculators leave out; the ten this page was checked against in September 2026 all left the rule unstated.
Original cost basis, and adjusted cost basis
The figure above is your original cost basis. It is what the shares cost you and nothing else: the share counts, the prices per share, and nothing added to or taken away from that money. An adjusted cost basis starts from the same figure and then carries the increases and decreases the tax rules call for. On stock, the usual downward adjustments come from a stock split, a stock dividend or a nondividend distribution, which is a return of your own money that reduces what the shares cost you. Commissions and other costs of buying move it the other way, upward.
This page makes no adjustment of any kind, because there is no field here for one. The division runs on the rows you typed and on nothing else, which is why the number here can differ from the number on a broker's tax report for the same holding: that report is an adjusted basis, and it carries purchase costs and corporate actions this page has no place to put. The three ways a sale can be matched against shares are set out with the IRS wording behind each one in the cost basis methods section of the home page; what comes back here is the average basis for the rows you enter.
If a split or a dividend has already happened on the position you are costing out, enter the rows as your holding stands now, with today's share count and today's cost per share. That is the honest way to use this page: it divides what you give it, and it will not pretend to know what happened to the position before then. The stock split calculator is the page for working out the new count and the new price from a split ratio if you need to get to that state first.
What goes in, and what stays outside
A row is two numbers: a share count and a price per share. That is the whole input, and it is the whole sum. Everything below is outside the page, with no box to put it in.
- Commissions and fees. No field for them. The usual way to work them in by hand: divide the commission by the shares in that purchase and add the result to the price before typing the row, so the row costs what the trade really cost you.
- Tax. This page knows nothing about a holding period, a bracket or a gain, and it shows no tax figure at all. What comes back is a cost, before anything a tax rule would do to it.
- Stock splits and other corporate actions. A split changes the share count and the price per share by the same factor. This page takes your rows exactly as typed and rescales nothing, so enter the rows as they stand after any action you want reflected.
- Currency. Every amount comes back in whatever currency you typed, and no exchange rate is applied anywhere. Rows typed in two different currencies would be added together as plain numbers, which would make the result meaningless, so keep one currency per run.
- Live prices. There is no quote feed wired into this page, so it cannot show you a price that you did not type. Nothing on the page comes from anywhere except your own rows.
One unit of this page's own arithmetic is worth knowing about. A price carrying more than two decimals, or a fractional share count, can leave a fraction of a cent on a row. Each row's cost is then shown cut short at two decimals while the total is the exact rows added up, so the printed rows can land a cent away from the printed total. With prices of two decimals or fewer the two always agree. The line under the results says so when it happens.
Nothing here is advice, and nothing here is a forecast: the page works on purchases that have already happened, at prices you already paid, and it says nothing about what the shares are worth now or later.
Frequently asked questions
Can I enter fractional shares, and is there a limit on how many rows?
Both work the way you would want. A share count takes decimals, so a purchase of 10.5 shares is one row like any other, and a run of 10.5 shares at $42.10 plus 4.25 shares at $40.00 returns a cost basis of 41.4949 across 14.75 shares. And there is no cap on rows: the page starts with three, + Add purchase adds as many as you need, and the × on a row takes it away. No counter, no round number to stop at.
Does cost basis round to the nearest cent?
Not on this page. It cuts the figure short at the stated decimal instead, so the number you read is never above the number the rows produce. A figure kept to whole cents elsewhere will have a rounded last digit, which is why the same three rows above can give 25.5805 here and a fraction more on a statement. If you need the rounded version, round it at the end yourself and note that you did; that is the only honest way to move a figure between the two rules.
How many decimal places should a cost basis be calculated to?
There is no single number the rules impose on a per-share cost basis, and anyone who tells you there is has gone past what the sources support. What matters is that the figure is carried far enough for the multiplication back out to stay within a cent, and that the rule is written down rather than left to the reader. This page keeps four decimals on the per-share figure and two on money, prints every step of the sum, and states the direction of the last digit in the section above. The choice of four is this page's own; the stating of it is not optional.
Can I see the arithmetic for each row, not just the answer?
That is what the box under the results is. Each row's own cost appears beside that row as you type it, then the whole sum is printed line by line below: every multiplication, the total cost, the total shares, and the division that gives the cost basis. Nothing on this page asks you to take a figure on trust, because every figure it shows can be checked against the two numbers on its own row.
Is there an account, a sign-up or a pop-up?
None of the three. Nothing opens over the page, nothing asks for an email address, and there is no account to create. The rows live in the browser tab and are gone the moment you close it, since the whole sum runs on your own device and nothing is sent anywhere.
Why is the cost basis per share not the plain average of my prices?
Because the purchases are not the same size. On the example above the three prices average 25.60 if you treat them as equals, while the cost basis comes out at 25.5805, because the largest purchase of the three was also the cheapest and it carries more weight. Weighting by share count is the whole point of the division, and a plain average of the prices is the figure to avoid when the purchases differ in size.
Will this match what my broker shows for the position?
It matches when both sides counted the same things, and the gap is always about what each side left out. This page divides the rows you typed. A broker's figure may carry commissions, may have been moved by a split or a dividend, and is often built from lots rather than one blend of everything. Compare the rows behind the two figures rather than the two figures alone, and where they differ, the difference is in what went in.