Average Cost Basis Calculator
Average cost basis for 225 shares across three lots totaling 10,060 dollars is 44.71 dollars a share. Selling 120 shares at 60 dollars produces a taxable gain of 1,826.67 dollars, leaving 105 shares with a remaining tax basis of 4,694.67 dollars.
Enter each purchase. Leave a row blank if you have fewer than six lots. Commissions are added to the cost of that lot.
The sale
| Average basis per share | |
| Shares owned | |
| Total cost, commissions included | |
| Shares sold | |
| Cost of the shares sold | |
| Proceeds after the sale commission | |
| Realized gain or loss | |
| Shares still held | |
| Basis left in the account |
Lot by lot
| Lot | Shares | Price | Cost | Per share |
|---|
Estimates only, not tax advice. All calculations run in your browser and nothing you type is sent anywhere.
Add every purchase and commission and the tool spreads the total across your shares, then shows what the shares you sold cost and what the sale gained or lost.
Key takeaways
- Average cost basis is total cost divided by total shares, with buy commissions added to the cost
- Three lots of 100, 50 and 75 shares cost 10,060 dollars in total, so 225 shares carry a 44.71 dollar basis
- Selling 120 shares at that basis releases 5,365.33 dollars of cost and leaves a 1,826.67 dollar gain
- Buy commissions raise the basis and sell commissions reduce the proceeds, so the two are never treated the same way
- The per share basis does not change when you sell, only when you buy, split or receive a return of capital
On this page
What average cost basis means
Cost basis is what you paid, not what the shares are worth today. Buy 100 shares at 40 dollars and pay a 5 dollar commission, and your basis in that lot is 100 x 40 + 5 = 4,005 dollars, or 40.05 dollars a share. Do that three times at three different prices and you own three lots with three different bases.
The average cost method collapses them into one number: total cost divided by total shares. It answers the question every seller faces, which is what the shares that just left the account cost you. Your broker reports the same figure on Form 1099-B for covered shares, so the tool is mostly a way to check their arithmetic before you file.
| Lot | Shares | Price paid | Commission | Cost of the lot | Basis per share |
|---|---|---|---|---|---|
| Lot A | 100 | 40.00 | 5.00 | 4,005.00 | 40.05 |
| Lot B | 50 | 52.00 | 5.00 | 2,605.00 | 52.10 |
| Lot C | 75 | 46.00 | 0.00 | 3,450.00 | 46.00 |
| Total | 225 | 10.00 | 10,060.00 | 44.71 |
The blended basis of 44.71 dollars a share is not the average of the three prices. The plain price average is (40 + 52 + 46) / 3 = 46.00 dollars, which is higher, because the 75 shares bought at 46 dollars carry less weight than the 100 bought at 40. Weighting by share count is the whole point of the method, and it is why a position built up over years drifts away from the simple average of the prices you remember.
The formula, run on three lots
The formula has two lines. Total cost is the sum of shares times price, plus every commission you paid. Average basis per share is that total divided by the share count.
For the three lots above: 100 x 40 + 5 = 4,005; 50 x 52 + 5 = 2,605; 75 x 46 + 0 = 3,450. Adding them gives 4,005 + 2,605 + 3,450 = 10,060 dollars across 225 shares, so 10,060 / 225 = 44.71 dollars a share. Nothing is estimated and nothing is rounded until the last step, which matters because rounding the per share basis early can shift a large sale by several dollars.
Now sell 120 shares at 60 dollars with an 8 dollar commission. Proceeds are 120 x 60 - 8 = 7,192 dollars. The cost released is the average basis times the shares sold, 44.7111 x 120 = 5,365.33 dollars, so the realized gain is 7,192 - 5,365.33 = 1,826.67 dollars. The 105 shares left behind carry the rest of the cost, 10,060 - 5,365.33 = 4,694.67 dollars, which is 44.71 dollars a share again.
That last check is worth doing on any statement you do not trust. Multiply the remaining basis by the shares left and divide by the shares sold. If the two per share figures disagree, a commission or a reinvestment is missing from the lot list.
A second run where the sale loses money
The method does not care whether the trade made money. Run a larger position bought at higher prices: 200 shares at 18.40 with no commission is 200 x 18.40 = 3,680 dollars. Another 300 at 22.10 with a 4.95 dollar commission is 300 x 22.10 + 4.95 = 6,634.95 dollars. A final 150 at 25.00 is 150 x 25 = 3,750 dollars.
Total cost is 3,680 + 6,634.95 + 3,750 = 14,064.95 dollars across 650 shares, so the basis is 14,064.95 / 650 = 21.6384 dollars a share. Notice how far that sits below the highest price paid. The 300 shares at 22.10 pull the average up, but the 200 cheap shares pull it back down.
Sell 400 shares at 19.25 with no commission. Proceeds are 400 x 19.25 = 7,700 dollars. The cost released is 400 of the 650 shares, which is 14,064.95 x 400 / 650 = 8,655.35 dollars. The result is 7,700 - 8,655.35 = -955.35 dollars, a realized loss.
That loss can offset gains elsewhere in the same tax year, subject to the wash sale rule if you buy the same security back within 30 days. The 250 shares left carry 14,064.95 - 8,655.35 = 5,409.60 dollars of basis, which is the same 21.6384 dollars a share. The per share figure does not move when you sell, and that stability is what makes the method easy to check years later.
Average cost against FIFO and LIFO
Average is one of three ways to answer the same question. FIFO sells the oldest shares first. LIFO sells the newest. Specific identification names the exact shares on the trade ticket. The IRS accepts all three if you keep records and apply your choice consistently.
Run the 120 share sale from the first example under each method. FIFO takes 100 shares from lot A at 40.05 and 20 from lot B at 52.10, and 20 x 52.10 = 1,042, so the basis is 4,005 + 1,042 = 5,047 dollars and the gain is 7,192 - 5,047 = 2,145 dollars. LIFO takes all 75 shares from lot C at 46.00 and 45 from lot B, and 45 x 52.10 = 2,344.50, so the basis is 3,450 + 2,344.50 = 5,794.50 dollars and the gain is 7,192 - 5,794.50 = 1,397.50 dollars. Average releases 5,365.33 dollars and reports a gain of 1,826.67 dollars.
| Method | Shares taken | Cost released | Gain on the sale |
|---|---|---|---|
| FIFO | 100 from lot A, 20 from lot B | 5,047.00 | 2,145.00 |
| LIFO | 75 from lot C, 45 from lot B | 5,794.50 | 1,397.50 |
| Average cost | 120 at the blended basis | 5,365.33 | 1,826.67 |
Same sale, same shares, three different tax bills: 2,145, 1,397.50 and 1,826.67 dollars. That spread is why brokers ask you to choose a method before the trade settles rather than after. It is also why a taxpayer in a high bracket may prefer the method that produces the smallest gain this year, even when a different method would produce a smaller gain overall.
Which costs belong in the basis
Basis is not just the share price. Anything you had to pay to own the shares goes in: commissions, transfer fees and the odd account fee a broker charges to move a position. Sell side costs work the other way, reducing what you receive rather than raising the basis.
| Item | Goes into basis? | Why |
|---|---|---|
| Buy commission | Yes | It is part of what the shares cost you |
| Transfer or account fee at purchase | Yes | Paid to acquire the position |
| Reinvested dividend | Yes | You already paid tax on the dividend, so it becomes new cost |
| Sell commission | No, it reduces proceeds | You never owned that money |
| Advisory fee billed per trade | Sometimes | Only when it is tied to a specific purchase |
| Return of capital distribution | No, it lowers basis | You already got that money back |
Reinvested dividends catch people every year. A 500 dollar dividend that buys 8.2 shares at 61 dollars adds 500 dollars to your basis, and the 1099-DIV has already reported that 500 dollars as income. Skip the step and you pay tax twice on the same money, once when the dividend lands and again when you sell the shares it bought.
Return of capital is the mirror image. A fund that pays out more than it earned lowers your basis instead of raising it, and the 1099-DIV shows that in a separate box. Enter those distributions as a negative cost if you want the average to stay honest.
Where the average method is allowed
IRS Publication 550 sets out the average basis method for mutual fund shares, and most fund companies apply it by default when you sell part of a position. For individual stocks the rule is narrower: average basis is available when you elect it and the shares are covered, which in practice means shares bought through a broker after 2011 that the firm tracks for you.
Two limits matter. You cannot switch methods for the same position whenever the answer looks better, because the election is sticky and undoing it takes a letter to the IRS. And once you use average basis for a fund, you keep using it for that fund, which is why an old statement may not match a fresh calculation after a split or a spin-off.
Splits are the usual reason a basis looks wrong. In a two for one split your 225 shares become 225 x 2 = 450 shares and the basis per share halves, 44.7111 / 2 = 22.36 dollars, while the total cost stays at 10,060 dollars. Nothing was gained or lost. A spin-off is harder, because part of the original basis moves to the new company at a ratio the parent publishes. The SEC investor education page on cost basis walks through both events, and the related spin-off calculator on this site handles the allocation arithmetic.
Reinvested dividends and fractional shares
Small numbers compound into a wrong answer. A 4.95 dollar commission on 300 shares works out to 4.95 / 300 = 0.0165 dollars a share, which looks like nothing until you sell 650 shares and the difference lands on a tax form. Two habits keep the record clean: enter commissions in their own field, and use the amount the broker charged rather than a rounded figure you remember.
Fractional shares are the second trap. A dividend reinvestment plan that buys 0.3472 shares at 61.20 dollars contributes 0.3472 x 61.20 = 21.25 dollars of basis. Round that to 0.35 shares and you overstate the position slightly, and the error repeats with every reinvestment until the share count is off by a full share.
The tool accepts fractional shares and prices to four decimals, so there is no reason to round on the way in. If you have 40 reinvestments, add them into six rows by combining the shares and the total cost for each period. The average is unaffected by how the lots are grouped, which is the one convenience the method offers over FIFO.
Keeping records that survive a review
The average method is only as good as the lot list behind it. Keep the confirmation for every purchase, the commission on each one and a note of any reinvestment. If you have held the position for 20 years, the early lots may be noncovered shares that the broker never reported to the IRS, and your own records are the only proof of what you paid.
Run the tool once a year rather than once a decade. Save the output next to that year's statement, so a question about the 2019 lots has an answer that does not depend on memory. When you sell, put the method in writing on the trade ticket: average, FIFO or specific identification. A broker who receives no instruction usually defaults to the oldest shares, and that default may not be the one you wanted.
One more habit for households: keep the basis record with the account paperwork, not in a folder that only one person knows about. Inherited shares get a stepped up basis to the value on the date of death, and the person handling the estate will need the original cost of every lot bought before that date to work out what the step up applies to.
This page is a calculator, not tax advice. Rules for state returns, wash sales and inherited shares differ, and a tax preparer can tell you which method fits your situation.
Frequently asked questions
What is average cost basis?
It is the total you paid for a position, commissions included, divided by the number of shares you own. Three lots costing 10,060 dollars for 225 shares give an average basis of 44.71 dollars a share.
How do you calculate average cost basis per share?
Add shares times price plus commission for every lot, then divide by total shares. For 100 shares at 40 with a 5 dollar fee and 125 shares at 48 with no fee, the cost is 4,005 + 6,000 = 10,005 dollars over 225 shares, so 44.47 dollars a share.
Do commissions go into the cost basis?
Yes, on the buy side. A 5 dollar commission on 100 shares raises the basis from 40.00 to 40.05 dollars a share. A commission on the sale is different: it reduces the proceeds instead of raising the basis.
Does average cost basis lower my taxes?
Not by itself. It changes when the gain appears, not the total gain over the life of the position. In the 120 share example, average basis produces a 1,826.67 dollar gain, FIFO produces 2,145 dollars and LIFO produces 1,397.50 dollars.
Can I use average cost basis for regular stocks?
Only if you elect it and the shares are covered by broker reporting, which usually means bought after 2011. Mutual funds are the natural home for the method, and most fund companies apply it by default.
What is the difference between average cost and FIFO?
FIFO sells your oldest shares first, so the gain depends on what you paid years ago. Average spreads the cost evenly across every share. On the same 120 share sale the two methods differ by 318.33 dollars of reported gain.
How do I handle a stock split?
Multiply the share count and divide the basis. A two for one split turns 225 shares at 44.71 dollars into 450 shares at 22.36 dollars, and the total cost stays at 10,060 dollars.
What happens if I sell at a loss?
The average basis still applies. Selling 400 of 650 shares with a 21.6384 dollar basis releases 8,655.35 dollars of cost against 7,700 dollars of proceeds, a 955.35 dollar loss that can offset other gains.
How are reinvested dividends treated?
Each reinvestment is a purchase. A 500 dollar dividend that buys 8.2 shares adds 500 dollars to your basis, and you have already been taxed on that 500 dollars as dividend income.
Does the average change when I sell shares?
No. The per share basis stays the same after a sale, which is why the remaining 105 shares in the first example still carry a 44.71 dollar basis. Only a new purchase, a split or a return of capital moves it.
What if I only sell part of my position?
The sale takes the same per share basis as the whole position. Selling 120 of 225 shares releases 120/225 of the total cost, which is 5,365.33 dollars out of 10,060 dollars.
How many lots can I enter?
Six rows, which is enough for most brokerage positions once you combine reinvestments by year. Grouping lots does not change the average, so six rows can hold hundreds of purchases.
Is average cost basis the same as dollar cost averaging?
No. Dollar cost averaging is a buying schedule that spreads purchases over time. Average cost basis is an accounting method for working out what the shares you sold cost, whatever schedule you used to buy them.
Where does the number on my 1099-B come from?
The broker computes it from the lots it has on file, using the method you elected or its default. Compare that figure with this tool before you file, especially if you transferred the position from another broker mid-year.
Spotted a wrong number or a broken result?
More Finance tools
- $100,000 Loan for 15 Years Calculator
- $15 an Hour Is How Much a Year?
- $15,000 Loan Over 5 Years Calculator
- $20 an Hour Is How Much a Year?
- $25 an Hour Is How Much a Year?
- $30 an Hour Is How Much a Year?
- 1 Year CD Rate Calculator
- 10 Year ARM Mortgage Calculator
- 10 Year Equipment Loan Calculator
- 10-Year Balloon Mortgage Calculator
- 10-Year Fixed Loan Calculator
- 10-Year Fixed Mortgage Calculator
- 10-Year Fixed Mortgage Rates Calculator
- 10-Year Second Mortgage Calculator
- 10/1 ARM vs 30 Year Fixed Calculator
- 1099 vs W-2 Calculator
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.