FIFO vs. LIFO cost basis: the same sale, two different gains
You bought the same stock twice, at two different prices, on two different dates. Now you sell part of the position. Which shares did you just sell — the ones you bought first, or the ones you bought most recently? The IRS lets you choose a method, and the choice changes both the taxable gain and whether it's taxed at the short-term or long-term rate.
The method
FIFO (first in, first out) matches a sale against the oldest open lots first. LIFO (last in, first out) matches it against the newest lots first. Whichever lots get consumed, the basis removed is shares taken from that lot × that lot's price per share — each lot keeps its own price, so a sale spanning two lots adds the basis from each separately. Gain is proceeds − total basis removed. The holding period travels with the lot: a lot held over one year is long-term, one year or under is short-term, and mixing lots in one sale can mean part of it is each.
A worked example
Two lots: 100 shares bought January 10, 2024 at $50/share ($5,000 basis), and 100 shares bought June 15, 2024 at $80/share ($8,000 basis). On February 1, 2025, you sell 150 shares at $90/share — proceeds of 150 × $90 = $13,500.
FIFO
- Oldest lot first: all 100 shares from the January lot, basis
100 × $50 = $5,000. - Remaining 50 shares from the June lot, basis
50 × $80 = $4,000. - Total basis:
$5,000 + $4,000 = $9,000. Gain:$13,500 − $9,000 = $4,500. - Holding period: the January lot was held 388 days (long-term); the June lot was held 231 days (short-term). This sale is split — part long-term, part short-term.
LIFO
- Newest lot first: all 100 shares from the June lot, basis
100 × $80 = $8,000. - Remaining 50 shares from the January lot, basis
50 × $50 = $2,500. - Total basis:
$8,000 + $2,500 = $10,500. Gain:$13,500 − $10,500 = $3,000. - Holding period: the June lot (100 shares, the larger piece this time) was held 231 days — short-term. The January lot (50 shares) was held 388 days — long-term.
Same 150 shares, same sale price, same $13,500 in proceeds — but FIFO reports a $4,500 gain and LIFO reports $3,000, a $1,500 difference, because the two methods disagree about which lot's price tag the sold shares are wearing. Neither number is wrong; they're two different, both-legal ways to answer a question the trade itself didn't record.
What this doesn't include
This is lot-matching arithmetic only. It applies no tax rate, computes no tax, and doesn't tell you which method you're allowed to use for a given account — some brokers default to FIFO or average cost and require you to elect otherwise in writing, and once a method is elected for an account it isn't always freely changeable. It doesn't check for wash sales. This is not tax advice; take the matched-lot figures to your broker's records and whoever prepares your return.
Run your own numbers
The free Tax Lot & Cost Basis Calculator tool takes a pasted list of buys, sells, reinvested dividends and splits, matches sells to lots under FIFO, LIFO, HIFO or specific ID, and shows the basis, gain and holding period for every matched lot — entirely on your device.