When you invest in stocks or bonds, your cost basis often will be the price you paid for the asset. However, it’s not always that simple. You’ll need to calculate your adjusted cost basis, which may be higher or lower than what you paid, if certain events occurred. Paying investment fees and commissions, although increasingly rare, would increase your adjusted cost basis. If you earned dividends or capital gains and you reinvested them, your cost basis also would increase by the amount you reinvested. If you sell stocks, bonds, mutual funds, or exchange-traded funds (ETFs), in a taxable account, your brokerage firm will send you IRS Form 1099-B. You’ll use that information to report your cost basis to the IRS on Form 8949 and on Form 1040, Schedule D.

Example of Cost Basis

For example, suppose you owned $1,000 of stock ABC and it paid a 2% dividend, which would amount to $20. If you reinvested the dividends, your adjusted cost basis would be $1,020. If you sold your shares for $1,500, your capital gain would be $480, based on the adjusted cost basis of $1,020, not your initial investment of $1,000. With real estate, cost basis is also used to calculate capital gains and losses. However, your adjusted basis can vary significantly from the price you actually paid for the property. If you made improvements to the property or paid to fix damages, your basis would increase. Depreciation, insurance payouts, and certain deductions can decrease your basis. When you inherit stocks or any other property, your basis isn’t what the owner paid for it. Instead, you’ll generally use the fair market value on the date of the individual’s death as your cost basis. This is known as a step up in basis. The rules are more complex when someone who is still living gifts you stock. For a detailed breakdown, check out IRS Form 550. Essentially, it boils down to the following:

Stock’s fair market value (FMV) is equal to or greater than the donor’s basis: Your basis is the donor’s basis.Stock’s FMV is less than the donor’s basis: Your basis is the fair market value on the date of the gift.

How to Calculate Cost Basis

Calculating cost basis can be challenging when you own a stock or mutual fund and you’ve made multiple buys at different prices. Let’s use an example to explain and illustrate the different ways you can calculate cost basis. Say you own 400 shares of Company XYZ’s stock. You purchased your shares over the course of four years:

January 2019: 100 shares at $10 per share, for $1,000 totalJanuary 2020: 100 shares at $12 per share, for $1,200 totalJanuary 2021: 100 shares at $15 per share, for $1,500 totalJanuary 2022: 100 shares at $16 per share, for $1,600 total

Your total investment amount is $5,300. In May 2022, you decided to sell 150 of your shares. Here’s how each method would work:

First-In, First-Out (FIFO)

The first shares you purchased are treated as the first shares you sell. This is the default method of the IRS and the method most brokerages automatically use. You sell all 100 of the shares you bought for $10 ($1,000), plus 50 of the shares you bought for $12 ($600). Your cost basis is $1,600.

Average Cost

You divide the total cost of all shares by the number of shares you hold, then use the average as your cost basis. This is only an option for mutual funds and certain dividend reinvestment plans (DRIPs). You can’t use the average cost method to calculate the basis for individual stocks. You take your total cost to purchase all of your shares, which is $5,300, and divide by 400. This brings your cost basis to $13.25 per share. Multiply that by the number of shares you’re selling, which is 150. Your cost basis is $1,987.50.

Specific Identification

You identify to your broker the specific shares you’re selling. You’ll need to tell your broker at the time of the sale that you’re using this method, so keep good records to document your basis. You choose which shares you want to sell. You could sell all 100 of the shares you bought for $16 ($1,600), plus 50 of the shares you bought for $15 ($750). That would make your cost basis $2,350. However, because you held the $16 shares for less than one year, you’ll be taxed at short-term capital gains tax rates. You could keep the $16 shares and sell all 100 of your $15 shares ($1,500), plus 50 of the shares you bought for $12 ($600). Your cost basis would be $2,100. Generally speaking, you’ll want a higher basis since it will reduce your capital gains, but this option could pay off if you’re taxed at long-term capital gains rates.

What It Means for Individual Investors

You only need to report your cost basis for investments you sell in taxable accounts. Cost basis doesn’t matter for tax-advantaged accounts, such as 401(k) plans, individual retirement accounts (IRAs), or 529 plans, because the growth in these accounts happens tax-free. Depending on the type of account, the money may be taxed as ordinary income when you withdraw it, but you won’t pay capital gains taxes on your investments. Generally, the lower your cost basis, the higher your potential capital gains. But, cost basis isn’t the only consideration when you’re trying to minimize capital gains taxes. As in the example above, selling securities you’ve held for one year or more typically comes with a lower tax rate. When you sell an investment you’ve held for less than one year, it’s treated as a short-term capital gain, and it’s taxed as ordinary income. If you’re an active trader, holding onto investments for at least one year may yield big tax savings. Long-term capital gains tax brackets are 0% or 15% for most investors, with the highest earners paying no more than 20% (although there are few other exceptions when the tax rate could be up to 28%).