How to Calculate Capital Gains on Your Investments

Advertisement

The formula for capital gains seems simple: sell price minus what you paid = gain. But the "what you paid" part -- your cost basis -- has nuances that trip up many investors. Using the wrong cost basis method can mean paying more tax than you owe, or reporting incorrectly on your return.

The Basic Formula

Capital Gain = Sale Price - Cost Basis - Selling Costs

Cost basis is generally what you paid for the asset, including any commissions or fees. Selling costs (broker commissions) reduce the gain.

Multiple Purchase Lots: Which Shares Are You Selling?

If you bought shares of the same stock at different times and prices, you have multiple "lots." When you sell some shares, you need to specify which lot you are selling -- or accept a default method. The choice affects your gain significantly.

Common cost basis methods:

  • FIFO (First In, First Out): The IRS default for stocks. The oldest shares are assumed sold first. In a rising market, oldest shares typically have the lowest basis and therefore the largest gain.
  • Specific identification: You designate exactly which shares to sell. Allows you to select high-basis shares (minimizing gain) or short-term loss shares. Must be designated at time of sale, not after.
  • Average cost: Default for mutual funds. All shares have the same average cost basis. Cannot be used for individual stocks.
  • LIFO (Last In, First Out): Rarely used for investments; more common in business inventory.

Dividend Reinvestments

When dividends are automatically reinvested to buy more shares, each reinvestment creates a new tax lot with a cost basis equal to the share price on the reinvestment date. These additional shares raise your overall cost basis -- reducing your eventual gain when you sell. Many investors forget to include reinvested dividends in their basis, inadvertently overpaying tax on gains they already paid tax on as dividend income.

Your brokerage should track this for you for shares purchased after 2011 (covered shares). For older shares (uncovered), you may need to reconstruct the history from statements.

Inherited Assets: The Step-Up in Basis

Assets inherited from someone who died receive a "step-up" in basis to the fair market value on the date of death. If a parent bought stock for $10,000 that is worth $80,000 at death, the heir's basis is $80,000 -- not $10,000. Selling immediately after inheriting triggers zero capital gains tax on the $70,000 appreciation. This is one of the most significant tax benefits in the code and a major estate planning consideration.

Gifted Assets: The Carryover Basis

Gifted assets (not inherited -- given while the donor is alive) carry over the donor's original basis to the recipient. If you receive stock with a $10,000 basis now worth $80,000, your basis is still $10,000 when you sell. The gain that built up during the donor's ownership comes due when you sell.

Reporting Capital Gains

Capital gains and losses are reported on Schedule D and Form 8949. Your brokerage sends a Form 1099-B showing proceeds from sales. You compare that to your records of cost basis to calculate the net gain or loss. Some brokerages report adjusted cost basis directly on the 1099-B; others report only proceeds, leaving basis calculations to you.

Use our Capital Gains Tax Calculator to estimate the tax on any sale once you have your gain calculated.

Cost Basis Methods and How They Affect Your Tax

The taxable gain on an investment sale isn't just the selling price minus what you remember paying. The IRS requires specific cost basis accounting, and your choice of method can meaningfully change your tax outcome in a given year.

What Counts in Your Cost Basis

  • Commissions and transaction fees: Add these to your purchase price. A $10,000 stock purchase with a $10 commission has a $10,010 basis.
  • Reinvested dividends: Dividends automatically reinvested in mutual funds and ETFs create additional shares with their own purchase dates and prices. These add to your cost basis. Missing reinvested dividends is one of the most common ways investors overstate their taxable gain.
  • Stock splits: A 2-for-1 split doubles your shares but halves the per-share basis. Total basis is unchanged.
  • Inherited assets: Inherited assets receive a stepped-up basis to fair market value at the date of death — meaning decades of appreciation can be tax-free to the heir.
  • Gifted assets: Gifted assets generally carry over the donor's original basis (carryover basis), not the current market value.

Cost Basis Methods for Mutual Funds

  • First In, First Out (FIFO): The default. Oldest shares sold first. In a rising market, this means the lowest-basis (highest-gain) shares are sold first.
  • Specific Identification: You designate exactly which shares you're selling. Allows you to sell high-basis shares first, minimizing the current-year gain. Requires documentation and communication with your broker but is the most flexible method.
  • Average Cost: Averages your total cost basis across all shares of the same fund. Simplest to calculate; moderates gains without minimizing them.

Holding Period and the Wash-Sale Rule

Each lot of shares has its own holding period starting the day after purchase. To qualify for long-term rates, you must hold for more than one year — selling on the one-year anniversary date is still short-term. The wash-sale rule disallows a loss if you buy a substantially identical security within 30 days before or after the sale. The disallowed loss is added to the basis of the replacement security instead. This rule applies across all your accounts, including IRAs.

Use our capital gains tax calculator to estimate the tax on your specific gain, and our 2026 capital gains rate guide for current income thresholds at each rate.

Advertisement