FIFO vs LIFO vs HIFO: how cost basis methods change your taxes

When you sell part of a position, which shares did you sell? A worked example showing how FIFO, LIFO and HIFO produce very different gains from the same trade.

Last reviewed 2026-09-17

If you bought the same stock more than once, each purchase is a separate tax lot with its own price and date. When you sell only some of your shares, the tax result depends on which lots you're treated as selling. The rule that decides that is your cost basis method.

The three methods

MethodSells firstTends to produce
FIFO — first in, first outYour oldest sharesLarger gains in a rising market, but more likely to be long-term
LIFO — last in, first outYour newest sharesSmaller gains in a rising market, but more likely to be short-term
HIFO — highest in, first outYour most expensive sharesThe smallest gain, or largest loss, on each sale

A worked example

Suppose you bought one stock three times:

LotBoughtSharesPriceCost
A1 Mar 202310$100$1,000
B1 Feb 202410$150$1,500
C1 Sep 202410$120$1,200

On 15 November 2024 you sell 10 shares at $140, for proceeds of $1,400. Here is the same sale under each method:

MethodLot soldCostGain / lossHolding period
FIFOA$1,000+$400Long-term (over 1 year)
LIFOC$1,200+$200Short-term
HIFOB$1,500−$100Short-term

One trade gives three different answers: a $400 long-term gain, a $200 short-term gain, or a $100 short-term loss. None of them is automatically "best":

What the IRS actually uses

This is the point most often misunderstood. Your broker's method is what counts, not the method in your tracker.

In short: decide on a method with your broker before you sell, then set Portfolio Tracker to match so its numbers agree with your 1099-B.

Short-term vs long-term

A gain is long-term if you held the shares for more than one year. The holding period starts the day after you buy. Shares bought on 1 March 2023 become long-term on 2 March 2024, not on 1 March. See IRS Publication 550.

Portfolio Tracker classifies a lot as long-term when it has been held for more than 365 days. That matches the IRS rule in almost every case. For a sale within a day or two of the one-year mark — especially one spanning a leap year — check the dates against your broker's records.

Using this in Portfolio Tracker

  1. Go to Settings → Data → Transactions and choose FIFO, LIFO or HIFO to match your broker.
  2. Every sale in the Transactions tab now shows the lot or lots it drew from, each with its own cost, gain and short- or long-term label.
  3. Before selling, open the Tax tab and click Lot Optimizer. It shows which lots to sell to reach a share count or target gain, and how the result splits between short- and long-term, so you can compare options before placing the order with your broker. The Lot Optimizer appears when Settings → Basics → Experience Level is set to Advanced.

Changing the method recalculates every past sale, so you can see what each method would have produced in earlier years too.