Cost basis methods for stocks: FIFO, LIFO, and specific identification

TrackMyShares Team

When you sell shares of a stock you have purchased multiple times at different prices, a simple question arises: which shares did you sell? The cost basis method you choose determines the answer, and it can make a real difference in how much tax you owe for the 2025 tax year (filed by April 15, 2026).

What is cost basis

Your cost basis is the total amount you paid to acquire an investment, including the purchase price and any commissions. When you sell, your gain or loss is the difference between sale proceeds and cost basis.

Capital Gain (or Loss) = Sale Proceeds - Cost Basis

Straightforward with a single purchase. But most investors buy the same stock multiple times. When you sell some (but not all) of your shares, you need a method to determine which shares you sold and what their cost basis was.

The example used throughout

To compare all three methods fairly, I will use the same scenario. You made these purchases of XYZ stock:

LotDateSharesPrice per shareTotal cost
Lot 1January 15, 2025100$40$4,000
Lot 2May 10, 2025100$55$5,500
Lot 3September 20, 2025100$45$4,500

You hold 300 shares with a total cost of $14,000. On December 15, 2025, you sell 100 shares at $60 per share ($6,000 proceeds). All three lots are still short-term at the time of sale.

Which 100 shares did you sell?

FIFO (First In, First Out)

FIFO sells your oldest shares first. It is the default at most brokers.

Under FIFO, you sell the 100 shares from Lot 1 (January 15, $40/share).

  • Cost basis: $4,000
  • Capital gain: $2,000 (short-term, held 11 months)

If you had waited one more month (until January 16, 2026), this lot would have qualified as long-term, potentially saving hundreds in tax.

FIFO is simple and automatic. You never need to decide which lots to sell. The downside: in a rising market, your oldest shares have the lowest cost basis, producing the largest gains.

LIFO (Last In, First Out)

LIFO sells your most recently purchased shares first.

Under LIFO, you sell the 100 shares from Lot 3 (September 20, $45/share).

  • Cost basis: $4,500
  • Capital gain: $1,500 (short-term, held ~3 months)

That is $500 less taxable gain than FIFO. At a 24% tax rate, you save $120.

LIFO works well when a stock has generally risen, because your newest shares tend to have higher cost bases. If the stock has been declining, LIFO could actually produce larger gains than FIFO.

Specific identification

Specific identification lets you choose exactly which lot to sell. You review all three and pick the best outcome.

LotCost basis per shareGain per share at $60Total gain
Lot 1$40$20$2,000
Lot 2$55$5$500
Lot 3$45$15$1,500

Choosing Lot 2 ($55/share) produces a gain of just $500. At 24%, that is $120 in tax, compared to $480 under FIFO and $360 under LIFO.

Specific identification gives you the most flexibility. It is ideal when you have lots at meaningfully different prices, want to minimize gains in a high-income year, maximize losses for tax-loss harvesting, or control whether gains are short-term or long-term. The tradeoff: you need to track every lot and designate which one you are selling at the time of sale. The IRS does not allow retroactive lot selection.

Side-by-side comparison

MethodLot soldCost basisGainTax at 24%
FIFOLot 1 ($40/share)$4,000$2,000$480
LIFOLot 3 ($45/share)$4,500$1,500$360
Specific IDLot 2 ($55/share)$5,500$500$120

That is a $360 difference on a single 100-share sale. Over a year of active trading, these differences compound.

Average cost: mutual funds only

The average cost method (total cost / total shares) is only available for mutual fund shares and shares acquired through dividend reinvestment plans, per IRS rules. You cannot use it for individual stocks or ETFs purchased on the open market.

How to choose

There is no universal best method. It depends on your situation.

If you are in a high tax bracket, minimizing gains through LIFO or specific identification saves real money. If you are in a low bracket (below the 0% long-term capital gains threshold for the 2026 tax year), you might want FIFO to realize gains at 0% while you can.

Sometimes the most tax-efficient lot is not the one with the highest cost basis, but the one that qualifies for long-term treatment. A $2,000 long-term gain at 15% ($300 tax) beats a $500 short-term gain at 37% ($185 tax) only at the highest bracket. For most people in middle brackets, the higher-cost lot still wins on absolute dollars. Run the numbers.

If you plan to hold remaining shares for years, the method mainly affects timing of when you recognize gains, not the lifetime total. But timing matters for cash flow and managing taxable income year to year.

If tax optimization is not a priority, FIFO is the easiest choice. No decisions, no tracking, and it is what your broker uses by default.

Changing your method at the broker

Most US brokers default to FIFO. You can usually change the default in account settings or select specific lots when placing a sell order. Some brokers also offer "highest cost" or "lowest cost" as automated variations. The IRS requires lot designation at the time of sale, not after.

How TrackMyShares handles cost basis

Every purchase you record is stored as a separate tax lot with its own date, quantity, price, and fees. TrackMyShares supports FIFO and specific identification, so you can see how each method would affect your gains before you sell.

The capital gains tax report shows the cost basis method used, the lot sold, holding period classification, and resulting gain or loss for every sale. This aligns with what you need for Form 8949 and Schedule D.

Sign up for TrackMyShares to track your lots, compare cost basis methods, and generate tax reports for the 2025 tax year.

This is general information, not personal tax or financial advice.