StockAvg

Cost Basis Calculator

Type each purchase on its own row, shares and the price per share you paid, and this cost basis calculator returns your cost basis per share, the total shares and the total cost of the position, with every step of the sum printed underneath from your own figures. An average cost basis calculator, a stock cost basis calculator, a stock average cost basis calculator and a cost basis of stock calculator are other names for that same division. No sign-up, no pop-up, no price feed: the rows are yours to type.

Each purchase

Shares Price per share Cost of this buy
Cost basis per share —
Total shares —
Total cost —

This is your original cost basis for these purchases: the money you put in, spread over the shares it bought. An adjusted cost basis is a different figure, the same basis after the increases and decreases the tax rules call for, so a stock split, a stock dividend or a return of capital moves it. Nothing on this page is adjusted.

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. Searched as a cost basis calculator stock, this is the stock version of that division: shares and a price per share on the way in, and the cost each share comes to on the way out.

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.

Three purchase rows added into one cost, then divided by the total shares A bar split into three segments of 255.50, 128.00 and 76.95, adding to a total cost of 460.45. An arrow leads down to the division by 18 shares, giving a cost basis of 25.5805 a share. Three rows, one total cost, one division 255.50 128.00 76.95 10 @ 25.55 5 @ 25.60 3 @ 25.65 total cost 460.45 divide by 18 shares (10 + 5 + 3) 25.5805 a share The widest block is the largest purchase, which is why the figure lands below the plain average of the three prices (25.60)

The three rows are added into one cost and then divided once. A row's price counts for as many shares as that row bought, so the widest block pulls the result furthest.

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.

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. It is not an adjusted cost basis calculator, and for that same reason: a split, a stock dividend, a return of capital and the commissions paid each call for a field of their own, and there is not one on this page. Shares that arrived by inheritance are the one case where the starting figure is not what was paid for them: the inherited stock cost basis calculator works the step-up at death on the same rows, and keeps the carryover rule for a gift apart from it.

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.

Restricted stock units and employee plan shares: which rows to type

Shares that came from an employer are costed by the same division as any other shares — what they cost you, divided by how many you got — and the only thing that differs is which number counts as the cost. The rest of this page applies unchanged: no lot names, no dates, no ordering, one row per purchase with a share count and a price. What follows sets out what goes on those rows for the two plans this question comes from most often, and where it stops short of choosing for you.

Restricted stock units (RSUs). An RSU is a promise rather than a purchase, so nothing is bought until it vests, and nothing is a cost to you until then either. The row is made from the day it vests: the shares you received as the share count, and the value of a share on that day as the price. That value is income to you in the year of vesting, reported by your employer like pay, which is the reason it becomes your cost — what you were taxed on is what the shares start at. Two things trip people typing these rows: shares withheld at vesting to cover tax never reach you, so the row carries the shares you actually received and not the larger number that vested; and a price taken from another day — the grant date rather than the vesting date — puts a different figure on the row, because the price that counts is the one from the day the shares vested to you.

Employee stock purchase plan (ESPP) shares. Here the purchase price is not the whole picture, and this is where the page stops choosing. Your employer buys the shares for you at a discount to the market price on the purchase date, and whatever that discount was worth is income to you — but which number goes into your cost depends on how long you hold the shares before selling, and there are two ways that can fall out.

Which of the two applies turns on how long the shares were held between the purchase date and the sale, and this page asks nothing about holding periods — so it cannot say which row yours is. Both above are stated so the choice is visible rather than silent, and the deciding factor is set out in IRS Publication 525 (and Publication 550 alongside it) for the year you file. Carry a copy of your own plan's statements with whichever you use, because the two rows do not produce the same figure and the difference is your own tax position, not an arithmetic one.

Typed out, both plans come back to the same two boxes. One row per event that gave you shares, at the price that day counts as your cost: a vest dated one day is one row, another vest two years later is a second row even though the company is the same, and the page has no cap on how many rows that takes. What the rows must not do is mix currencies, mix a withheld-shares count with a received-shares count, or carry a price from a day other than the one that set the cost — each of those is a row typed wrong rather than a plan handled wrongly, and the division above will divide whatever you give it without complaint.

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.

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.

Why "stock cost basis calculator" lands on this page

A stock cost basis calculator, an average cost basis calculator and a cost basis of stock calculator are three names for one sum: add what every purchase cost, divide by every share those purchases bought. The arithmetic has no separate version for stock, so there is no separate page for it here. What differs between the three names is only what the person typing them meant, and someone looking for a stock cost basis calculator usually means this: shares bought at more than one price, and one figure per share to carry forward. That is what the rows above produce.

Two things sit behind that figure and are worth naming before you carry it anywhere. The first is the method. Averaging every purchase into one figure is one of three ways a sale can be matched against shares, and on ordinary stock held in a brokerage account it is the narrow one: a sale there is matched by first in, first out, or by naming the shares sold. The second is adjustment. The figure here is an original basis, the money the shares cost, and a basis on a real position often moves after that: a split, a return of capital, a commission, or a loss that a wash sale pushed onto the replacement shares. When one of those has happened, the figure this page gives you is the starting point for the adjusted one, not the adjusted one itself. The wash sale cost basis calculator handles that last case, a disallowed loss added back onto what the replacement shares cost.

Frequently asked questions

How to calculate cost basis on shares bought in more than one purchase?

Put each purchase on its own row — the shares it bought and the price per share — and the page does the rest: every row is multiplied out into the money it cost, those amounts are added, and the total is divided by every share the rows bought. That is the whole method, and the printed lines under the results are it, one step at a time. Nothing else goes in: no date, no lot, no sale price and no commission field.

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.

How do I work out cost basis on RSUs?

One row per vesting date, with two figures: the shares that reached you on that day, after any shares were withheld to cover tax, and the value of one share on that same day. There is nothing else to type — no grant price and no separate income line, because the value on vesting day is what your employer reported as income and therefore what your shares start at. Several vestings is several rows, even for the same company, and the page averages them together like any other purchases.

How do I work out cost basis on ESPP shares?

The row is your purchase price plus whatever part of the discount was treated as income — but which of two figures goes there depends on how long you held the shares before selling, and this page asks nothing about holding periods, so it stops at naming both rather than picking one. One way adds the income amount to what you paid; the other puts the share price from the purchase date straight onto the row. The deciding factor and its thresholds are set out in IRS Publication 525 for the year you file; whichever you use, the shares go in as one row with that one price, and several purchase dates are several rows.

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.

How does the IRS know your cost basis?

Two channels, and only one of them carries a number. For a covered security your broker reports the basis on Form 1099-B, and the IRS spells out what lands on that form: "the date of acquisition (box 1b), whether the gain or loss is short-term or long-term (box 2), cost or other basis (box 1e), and the loss disallowed due to a wash sale (box 1g) or the amount of accrued market discount (box 1f)". Stock acquired after 2010 is covered, and so are shares acquired after 2011 in a mutual fund or other regulated investment company, or through a dividend reinvestment plan. The wash sale figure in that same list, box 1g, is worked out lot by lot on the wash sale cost basis calculator. Earlier than that, the IRS says the broker was not required to keep track of the basis at all, and that "you will need to determine date of acquisition and basis from available records". On those sales the basis is yours to work out and to stand behind.

The figure handed to the IRS is not the figure this page prints, and the IRS states the limit in one sentence: "Except for certain mutual fund shares and certain dividend reinvestment plans, you can't use the average basis per share to figure gain or loss on the sale of stock." A stock sale is reported lot by lot, and the average this page returns is not any one of those lots. Take 100 shares at 40.00 and 100 shares at 60.00: this page blends them into 10,000.00 across 200 shares, an average of 50.0000. Sell 100 of those shares at 70.00 and the proceeds are 7,000.00 on either reading. Against the average, 100 shares at 50.0000 is a basis of 5,000.00 and a gain of 2,000.00. Against the earliest lot, the basis is 4,000.00 and the gain is 3,000.00. The same two purchases, the same sale, and 1,000.00 between them, and the one that reaches the IRS is the lot.

Nothing typed here goes anywhere: there is no account, nothing is stored and no form is filled in, so these rows are yours to keep. The IRS line on records is that you "keep and maintain records that identify the basis of all capital assets", and that is what this page is for: type the purchases once, keep the rows, and check the arithmetic against box 1e when the 1099-B arrives. If the two disagree, the disagreement is in what each side counted, not in the division. Sources: IRS "Stocks (options, splits, traders)" and Topic no. 703, Basis of assets. This page files nothing and reports nothing on your behalf.

How do I find out my cost basis?

Start with the records, not with this page: it cannot look anything up. There is no ticker box, no quote feed and no way into your account here, so every figure it prints comes out of rows you typed. What it can do, once the purchases you can still document are in, is put a number on the one you cannot.

Take two lots you do have: 90 shares at 41.00 and 70 shares at 62.00. The page adds them to 8,030.00 across 160 shares and returns 50.1875. Now say you also remember buying shares in a year when the price ran between 30.00 and 70.00, and you can find neither the share count nor the price. Put 20 shares in at the low end and the average lands at 47.9444; put them at the high end and it lands at 52.3888. The answer is not one figure, it is a band 4.4444 wide, and the 50.1875 you already had sits inside it. Make it 100 shares instead and the same two prices open the band to 42.423 on one side and 57.8076 on the other, 15.3846 wide.

One multiplication sets that width: the missing shares' share of the shares you would hold afterwards, times how wide the price range was. 20 out of 180 shares is 11.1111%, and 11.1111% of a 40.00 range is 4.4444. 100 out of 260 shares is 38.4615%, and 38.4615% of the same range is 15.3846. A lot you cannot find is not one missing number, it is a missing range, and this page will print how wide that range is if you give it both ends. Should that lot turn out to have cost nothing at all, the same division puts the average at 44.6111 for 20 shares and 30.8846 for 100.

Two things the page will not do with that band. It will not choose an end for you: the advice usually given when a basis has to be reconstructed is to take the low end of the year's range, because a lower basis leaves a larger gain to be taxed, but that choice is yours, and it is one worth writing down together with where the price range came from. And it does not know what your broker has on file, which is a separate question from what the shares cost you.

The two lots you do have, 90 shares at 41.00 and 70 shares at 62.00, give 50.1875 across 160 shares. Each bar is where the average can land once a purchase you cannot find is added: 20 missing shares open 47.9444 to 52.3888, 100 missing shares open 42.423 to 57.8076. Both bars are the same page division, cut short at four decimals.

One purchase you cannot find: how far it can move the average you already have Two known lots, 90 shares at 41.00 and 70 shares at 62.00, give a cost basis of 50.1875 across 160 shares. Adding 20 unknown shares bought somewhere between 30.00 and 70.00 moves that average to anywhere between 47.9444 and 52.3888, a band 4.4444 wide. Adding 100 unknown shares over the same price range moves it to between 42.423 and 57.8076, a band 15.3846 wide. The known 50.1875 sits inside both bands. One purchase you cannot find: the band it opens Known lots: 90 at 41.00 and 70 at 62.00, an average of 50.1875 across 160 shares. The missing lot is priced somewhere between 30.00 and 70.00. 100 shares missing 42.423 57.8076 20 shares missing 47.9444 52.3888 50.1875 with the lots you have 40.00 45.00 50.00 55.00 60.00 Width of the band: 15.3846 for 100 missing shares, 4.4444 for 20. Both are the missing shares' share of the shares you would hold, times the 40.00 price range. The page picks neither end. It prints the range and leaves the choice, and the reason for it, to you.

This page is a calculator, not investment advice. A cost basis figure says what you paid for the shares; it says nothing about what they are worth now. Contact: contact@stockavg.com