Portfolio & Risk
How to Calculate Cost Basis, With Worked Examples
Cost basis sounds like a chore until you realize it decides your tax bill. The number your broker shows is usually right. Usually is the word that costs money.
Cost basis is what you paid for an investment, adjusted for events that happened while you held it. It is the number subtracted from your sale proceeds to work out the capital gain you owe tax on. Pay 5,000 dollars for shares, sell them for 8,000, and if your basis is correct you are taxed on 3,000. Get the basis wrong on the low side and you hand the government tax on money you never earned. The broker usually tracks it for you. Usually is the word that costs people money.
The simple case first
Start with one clean purchase. You buy 100 shares at 50 dollars and pay a 5 dollar commission. Your cost basis is the whole outlay, 100 x 50 + 5 = 5,005 dollars, or 50.05 a share. Sell later for 8,000 and your taxable gain is 8,000 - 5,005 = 2,995.
That is the entire idea in one line. Basis is total cost in, fees included. Everything after this is adjustment, nudging that one number up or down for the splits, dividends and distributions that happen in the years between the day you buy and the day you finally sell.
When you bought at different prices
Few people buy once. You add over months or years, at different prices, and now the question is which shares you are selling. Two methods answer it.
Average cost is the simple one. Add up every dollar you put in, divide by the total shares, and you have one blended figure to use for whatever you sell. Buy 100 at 50 and later 100 at 70, and your average basis is (5,000 + 7,000) / 200 = 60 dollars a share, so a sale of 100 shares carries a basis of 6,000 no matter which of the two lots you feel you are actually selling, because the method deliberately stops tracking them as separate purchases.
Specific identification is the powerful one. You name the exact shares you sell, lot by lot. That is the whole advantage, because facing the same sale you can hand over the 70-dollar shares to shrink the gain this year, or deliberately pick the 50-dollar shares to realize more gain when it suits you, turning a routine sale into a small act of tax planning. It takes records. It has to be elected at the time of sale. It usually saves the most.
The adjustment everyone forgets
Reinvested dividends are where most cost basis errors live, and the error always runs the same way.
A dividend is cash the company pays you, and you owe tax on it the year it lands. Reinvest it, and that cash quietly buys new shares. Those shares were bought with money you already paid tax on, so each one carries its own basis equal to the dividend that funded it, and if you forget to add that basis in when you sell, you count the same money twice, first as the dividend you were taxed on and again as a phantom gain the tax system now bills you for a second time.
Walk it through. You buy 100 shares at 50, a 5,000 basis. Over the years the stock pays dividends that you reinvest, buying 12 more shares for a total of 800 dollars. Your real basis is now 5,000 + 800 = 5,800 across 112 shares. Sell the lot for 9,000 and the true gain is 9,000 - 5,800 = 3,200. Forget the reinvested 800 and you would report a 4,000 gain, paying tax on an extra 800 dollars you already paid tax on once. The fix is to count every reinvested dividend as a purchase, which it is. The behavior of those dividends in the first place is covered in the dividend investing guide.
Splits change the shares, not the total
A stock split rearranges your basis without changing it. The total you paid is fixed, and the split just spreads it over a new share count.
Say your 100 shares at a 50 basis, 5,000 total, go through a 2-for-1 split. Now you hold 200 shares. The per-share basis halves to 25. The total is still 5,000, and nothing taxable has happened at all. A reverse split runs the other way, fewer shares at a higher basis each, and again the total holds exactly where it was. Track the new per-share figure. That is the number you use when you sell part of the position. The mechanics of why companies split at all sit in stock splits explained.
When the broker figure is wrong
Brokers are required to track and report basis for most shares bought in recent years, and for those the number they give you is reliable. The gaps are specific, and they are where mistakes hide.
Shares transferred in from another firm may arrive without basis history. Inherited shares usually reset to their value on the date of death, a step-up the broker may not know. Gifted shares carry the giver’s original basis, which the broker almost never has. And lots bought before the reporting rules took effect are simply outside the system. In each of these the broker may show a blank, a zero, or an estimate, and a zero basis means you are taxed on the entire sale proceeds as if the shares were free.
The habit that protects you is dull and effective. Keep your own trade confirmations, and check the broker basis against them before you file, especially on anything inherited, gifted or transferred. The tax you save by catching one wrong basis can dwarf a year of careful investing, which is the same quiet, compounding theme that runs through tax-efficient investing. The number is only a chore until the year it is wrong.
Frequently asked questions
What is cost basis?
Cost basis is the total amount you paid to acquire an investment, including commissions and fees, used to work out your taxable gain or loss when you sell. Sell for more than your basis and the difference is a capital gain. Sell for less and it is a loss. Getting the basis right is what keeps you from paying tax on money you never made.
How do I calculate cost basis for stocks bought at different times?
You have two main methods. Average cost adds up everything you paid and divides by total shares, giving one blended figure. Specific identification lets you choose which shares you are selling, so you can pick high-basis lots to reduce the gain. Specific ID usually saves more tax but requires records and must be elected at the time of sale.
Do reinvested dividends count toward cost basis?
Yes, and forgetting them is the most common cost basis error. Each reinvested dividend buys new shares with money you already paid tax on, so those shares carry their own basis equal to the dividend amount. Leave them out and you count that income twice, once as a dividend and again as a phantom gain when you sell.
How does a stock split affect cost basis?
A split changes your share count and your per-share basis but never your total basis. After a 2-for-1 split you own twice the shares at half the basis each, and the total you paid is unchanged. The same logic runs in reverse for a reverse split, fewer shares at a higher basis each.
Is the cost basis my broker reports always correct?
Not always. Brokers must track basis for most shares bought in recent years, but gaps appear with shares transferred from another firm, inherited or gifted holdings, and older lots from before the reporting rules. The broker figure is a strong starting point, and checking it against your own records is what catches the expensive mistakes.