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
| Method | Sells first | Tends to produce |
|---|---|---|
| FIFO — first in, first out | Your oldest shares | Larger gains in a rising market, but more likely to be long-term |
| LIFO — last in, first out | Your newest shares | Smaller gains in a rising market, but more likely to be short-term |
| HIFO — highest in, first out | Your most expensive shares | The smallest gain, or largest loss, on each sale |
A worked example
Suppose you bought one stock three times:
| Lot | Bought | Shares | Price | Cost |
|---|---|---|---|---|
| A | 1 Mar 2023 | 10 | $100 | $1,000 |
| B | 1 Feb 2024 | 10 | $150 | $1,500 |
| C | 1 Sep 2024 | 10 | $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:
| Method | Lot sold | Cost | Gain / loss | Holding period |
|---|---|---|---|---|
| FIFO | A | $1,000 | +$400 | Long-term (over 1 year) |
| LIFO | C | $1,200 | +$200 | Short-term |
| HIFO | B | $1,500 | −$100 | Short-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":
- HIFO minimises the gain today, but it keeps your cheapest shares, so there's a larger gain waiting when you sell those later.
- FIFO gives the biggest gain here, but because it's long-term it may be taxed at a lower rate than a smaller short-term gain.
- Which one costs less overall depends on your tax bracket, your other gains and losses that year, and what you plan to do with the remaining shares.
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.
- If you don't identify which shares you sold, the IRS treats the sale as FIFO — the oldest shares first (Treasury Regulation §1.1012-1(c)).
- To use another method, you specifically identify the shares to your broker by the time of the sale. LIFO and HIFO are ways of doing that. Most brokers let you set a standing default method in your account settings.
- Your broker reports cost basis on Form 1099-B using the method on your account. Choosing HIFO in a tracker does not change what your broker reports.
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
- Go to Settings → Data → Transactions and choose FIFO, LIFO or HIFO to match your broker.
- 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.
- 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.