$Missed Deductions

How do I calculate cost basis for stocks I sold?

Retirement & Investingintermediate3 answers · 7 min readUpdated February 28, 2026

Quick Answer

Cost basis is your original purchase price plus any fees, adjusted for stock splits and dividends. For stocks bought at different times, you can choose specific identification, FIFO (first in, first out), or average cost methods. Choosing the highest cost basis shares minimizes your taxable gain — potentially saving 15-37% in taxes.

Best Answer

RK

Robert Kim, Tax Return Analyst

Investors who bought stocks at different times and prices

Top Answer

What is cost basis?


Cost basis is your original investment amount used to calculate capital gains or losses when you sell. According to IRS Publication 551, it includes the purchase price plus any fees, commissions, or other costs. The method you choose to calculate cost basis can significantly impact your tax bill.


The four main cost basis methods


Method 1: Specific Identification (Best for tax savings)

You choose exactly which shares to sell. This gives you maximum control over your tax outcome.


Example: You bought Microsoft stock in three purchases:

  • January 2024: 100 shares at $300 = $30,000
  • June 2024: 100 shares at $250 = $25,000
  • March 2025: 100 shares at $400 = $40,000

  • In December 2026, Microsoft trades at $350. You want to sell 100 shares ($35,000).


    If you specify the March 2025 shares (highest cost):

  • Sale proceeds: $35,000
  • Cost basis: $40,000
  • Result: $5,000 capital loss (tax benefit)

  • If you let FIFO apply (January 2024 shares):

  • Sale proceeds: $35,000
  • Cost basis: $30,000
  • Result: $5,000 capital gain (tax owed)

  • Tax difference: $10,000 swing! At 15% long-term capital gains rate, that's $1,500 in tax savings.


    Method 2: First In, First Out (FIFO) - Default method

    Your broker automatically sells the oldest shares first. This often creates larger gains as older shares typically have lower cost basis.


    Method 3: Average Cost (Mutual funds only)

    All shares are averaged together. You can't pick and choose specific shares.


    Method 4: Last In, First Out (LIFO)

    Sells newest shares first. Often better for tax purposes than FIFO but not as flexible as specific identification.


    Step-by-step cost basis calculation


    Step 1: Start with purchase price

  • Original purchase: $10,000 for 100 shares = $100/share basis

  • Step 2: Add fees and commissions

  • Trading fee: $10
  • Adjusted basis: $10,010 for 100 shares = $100.10/share

  • Step 3: Adjust for corporate actions

  • 2-for-1 stock split: Now own 200 shares
  • New basis: $100.10 ÷ 2 = $50.05/share

  • Step 4: Calculate gain/loss on sale

  • Sell 100 shares at $75/share = $7,500
  • Cost basis: 100 × $50.05 = $5,005
  • Capital gain: $7,500 - $5,005 = $2,495

  • Common cost basis adjustments



    Key strategies for minimizing taxes


    Strategy 1: Harvest losses first

    Sell losing positions before winners to offset gains.


    Strategy 2: Specify high-basis shares

    Always identify the highest cost basis shares when selling winners.


    Strategy 3: Avoid wash sale rules

    Don't buy the same stock within 30 days of selling at a loss, or you lose the tax deduction.


    Strategy 4: Track everything

    Keep detailed records of all purchases, including dividend reinvestments and stock splits.


    What you should do


    1. Review your broker statements for cost basis information — many brokers now track this automatically

    2. Choose specific identification for future sales to maximize tax control

    3. Keep detailed records of all transactions, especially for older positions

    4. Consider tax-loss harvesting before year-end to offset any gains


    Use our refund-estimator tool to see how different cost basis methods could impact your tax refund, and ensure you're not overpaying on investment taxes.


    Key takeaway: Choosing the right cost basis method can save thousands in taxes — specific identification gives you maximum control, potentially turning a $5,000 taxable gain into a $5,000 tax-saving loss on the same sale.

    Key Takeaway: Proper cost basis calculation using specific identification method can save thousands in taxes by allowing you to choose which shares to sell, potentially turning gains into losses.

    Comparison of different cost basis methods and their tax impact

    MethodControl LevelBest ForTax Impact Example
    Specific IdentificationMaximumActive tax managementCan choose $40k basis vs $30k basis = $1,500 tax savings
    FIFO (Default)NoneSimple trackingOften creates larger gains as older shares have lower basis
    Average CostNoneMutual funds onlySmooths out basis differences, moderate tax impact
    LIFONoneGenerally better than FIFOUsually creates smaller gains than FIFO

    More Perspectives

    RK

    Robert Kim, Tax Return Analyst

    New investors who may not have detailed records of their stock purchases

    Cost basis for beginners: Start with good habits


    If you're new to investing and haven't been tracking cost basis, don't panic. Most brokers started providing cost basis information automatically in 2011, so your statements likely have what you need.


    What to do if you're missing records


    For stocks bought after 2011: Your broker's 1099-B should include cost basis. Double-check it's accurate.


    For older stocks: You'll need to reconstruct your basis using:

  • Old brokerage statements
  • Bank records showing transfers to investment accounts
  • Historical stock price websites (Yahoo Finance, etc.)
  • Dividend reinvestment records

  • Simple cost basis example for app-based trading


    Let's say you use Robinhood and bought GameStop stock during the 2021 hype:

  • February 2021: 10 shares at $100 = $1,000
  • March 2021: 5 shares at $200 = $1,000
  • December 2026: Sell 10 shares at $50 = $500

  • Using FIFO (automatic): You sold the February shares

  • Proceeds: $500
  • Cost basis: $1,000
  • Capital loss: $500 (good for taxes!)

  • Key lesson: Even with losses, you still need to report the sale and calculate basis correctly.


    Set up good tracking now


    1. Screenshot your purchase confirmations — apps sometimes don't keep long-term records

    2. Use specific identification for future sales to control your taxes

    3. Track dividend reinvestments separately if you have DRIP plans

    4. Keep a simple spreadsheet with date, shares, price, and total cost


    Key takeaway: Start tracking cost basis now even if you missed it before — your future tax savings will thank you, and most brokers provide the data automatically for recent purchases.

    Key Takeaway: New investors should start tracking cost basis immediately and use specific identification for future sales to control tax outcomes, even if past records are incomplete.

    RK

    Robert Kim, Tax Return Analyst

    Long-term investors with decades of stock purchases and dividend reinvestments

    Cost basis complexity for long-term investors


    As a long-term investor, you likely have the most complex cost basis situations: multiple purchase dates, stock splits, spin-offs, dividend reinvestments, and merger adjustments spanning decades. Proper tracking becomes even more critical as your portfolio grows.


    Managing dividend reinvestment plans (DRIPs)


    DRIP plans create new cost basis entries every quarter, sometimes for fractional shares. Each dividend reinvestment is treated as a separate stock purchase.


    Example: You owned 100 shares of Johnson & Johnson for 20 years with quarterly dividend reinvestments. You now have 127.3 shares with dozens of different cost basis entries. When you sell 50 shares, which ones are you selling?


    Strategy: Use average cost method for mutual funds with DRIPs, but specific identification for individual stocks to maximize control.


    Handling corporate actions over decades


    Stock splits: Your 100 shares of Apple from 1990 became 2,800 shares after multiple splits. Original $1,000 basis is now $0.36 per share.


    Spin-offs: When AT&T spun off parts of the company, you had to allocate your original AT&T basis between the remaining company and the new entities based on their relative values.


    Mergers: Cash and stock deals require different basis calculations and may trigger immediate taxable events.


    Tax-efficient withdrawal strategy


    As you near or enter retirement, coordinate cost basis selection with your overall tax strategy:


    1. Harvest losses in taxable accounts while taking gains from tax-advantaged accounts

    2. Use high-basis shares for current income needs

    3. Save low-basis shares for estate planning (heirs get stepped-up basis)

    4. Consider Roth conversions in low-income years instead of realizing taxable gains


    Key takeaway: Long-term investors need sophisticated cost basis tracking but gain the most from tax optimization — proper planning can save tens of thousands in taxes during retirement withdrawals.

    Key Takeaway: Long-term investors with complex portfolios benefit most from meticulous cost basis tracking and strategic share selection, potentially saving tens of thousands in retirement taxes.

    Sources

    cost basisstock salescapital gainsinvestment taxes

    Reviewed by Robert Kim, Tax Return Analyst on February 28, 2026

    This content is for educational purposes only and is not a substitute for professional tax advice. Consult a qualified tax professional for advice specific to your situation.