Cost Basis Explained: How Gains Are Measured When You Sell
Your taxable gain is the sale price minus your cost basis. When you've bought shares at different prices, the method used to pick which shares you sold changes the gain. Here is an example.
When you sell an investment in a taxable account, the gain or loss is the difference between what you sell it for and its cost basis, generally what you paid plus certain costs. When you've bought the same investment several times at different prices, which shares you're deemed to have sold matters, and the method used can change your taxable gain.
The basic formula
Cost basis usually includes the purchase price plus some transaction costs. Reinvested dividends count as new purchases, each with its own basis, which is why reinvested dividends aren't taxed again when you sell.
Example: three methods, three answers
A hypothetical investor bought:
- 100 shares at $50 (Lot 1)
- 50 shares at $60 (Lot 2)
Later, they sell 80 shares at $70.
| Method | Which shares are sold | Basis of shares sold | Gain |
|---|---|---|---|
| First in, first out (FIFO) | 80 from Lot 1 | 80 × $50 = $4,000 | $1,600 |
| Average cost (common for mutual funds) | 80 at average $53.33 | about $4,267 | about $1,333 |
| Specific identification | 50 from Lot 2, 30 from Lot 1 | $3,000 + $1,500 = $4,500 | $1,100 |
Show the numbers behind this chart
| Gain | |
|---|---|
| FIFO | $1,600 |
| Average cost | $1,333 |
| Specific ID (highest cost first) | $1,100 |
Same sale, same proceeds of $5,600, and the reportable gain ranges from $1,100 to $1,600.
Holding periods
How long you held the specific shares sold determines whether a gain is short-term or long-term. Long-term gains, generally on assets held more than a year, are usually taxed at lower rates than short-term gains. Choosing which lots to sell can therefore affect both the size of the gain and the tax rate on it. Current rates and rules are in IRS publications.
How brokers handle it
Brokers are generally required to track and report cost basis for securities bought after certain dates. Each account has a default method, often FIFO for stocks and average cost for mutual funds, and many brokers let you choose a different default or pick specific lots at the time of sale. Methods for some investments can't easily be changed after the fact, so set your preference before selling.
Special cases
- Inherited assets generally receive a basis adjusted to fair market value at the date of death, under current law.
- Gifted assets generally carry over the giver's basis, with special rules if the value has fallen.
- Wash sales can disallow a loss and shift it into the basis of replacement shares; see the wash sale rule.
- Corporate actions such as splits and spinoffs adjust basis.
The takeaway
Your gain depends on the basis of the specific shares sold. Knowing your lots, choosing the right method, and keeping records can lower taxes legitimately. For significant sales, a tax professional can help.
Keep reading
Asset Allocation and Rebalancing: Keeping Your Risk Where You Set It
A 60/40 portfolio left alone through a few good stock years quietly becomes a 70/30 portfolio. Here is how drift happens, what rebalancing does and doesn't do, and the main ways people rebalance.
Guide, 4 min readBond Basics: Why Bond Prices Fall When Rates Rise, and What Duration Tells You
Bonds are often described as safe, yet bond funds can lose money. The reason is the seesaw between interest rates and prices. Here is how it works, with prices calculated for three maturities.
Guide, 5 min readDollar-Cost Averaging vs. Lump Sum: What the Math Actually Says
If you have a large sum to invest, should you put it in all at once or spread it out? We ran both approaches through three market paths to show who wins, when, and why.
Guide, 4 min read