VistaCover

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.

Investing Article, 2 min read

Education, not advice. This page explains how things generally work. It doesn't consider your situation and isn't a recommendation. See our full disclaimer.

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

Gain or loss = Sale proceeds − Cost basis

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
Taxable gain on the same sale, by method
$0$400$800$1,200$1,600$2,000$1,600FIFO$1,333Average cost$1,100Specific ID (highest cost first)
Selling 80 shares at $70 after buying 100 at $50 and 50 at $60. Illustrative. Holding periods also affect tax rates.
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

Ask a question about this page

Spotted an error, or something here isn't clear? Tell us. We use messages to fix and improve our articles. We can't give personal advice or quotes, and we don't pass your details to anyone who sells insurance.

Please don't include policy numbers, account numbers, health details, or other sensitive information. See our privacy policy.