← All resources

Cost basis explained: FIFO vs LIFO vs average

FIFO, LIFO and average cost can turn one sale into three different gains. What each method does, and which ones IRS rules allow for stocks and funds.

The Tradune team · ·7 min read
Educational — not investment or tax advice · Last updated

The short answer

FIFO, LIFO and average cost are three rules for deciding which shares you sold when you bought at different prices. On a rising stock FIFO usually shows the largest gain, LIFO the smallest, and average a blend. For US taxes, FIFO is the default for stocks, LIFO-style results need specific identification, and average cost is allowed only for mutual fund and certain DRIP shares.

You buy the same stock three times over two years, then sell half your position. Simple question: what did those shares cost you? It turns out there isn’t one answer — there are at least three, and each one hands you a different capital gain, which means a different tax bill. The number you report depends entirely on an accounting choice most people never realize they’re making.

That choice is your cost-basis method, and the three you’ll meet are FIFO, LIFO, and average cost. None of them is a trick or a loophole. They’re just different rules for deciding which shares you sold when you didn’t sell all of them.

Why can the same sale have more than one cost basis?

Because you bought the shares at different prices, and nothing on the sale says which ones left. Cost basis is what you paid for a share, and it’s the number the taxman subtracts from your sale price to figure your gain. If you’d bought your entire position in one go, there’d be nothing to discuss — every share cost the same. The ambiguity only shows up when you bought at different prices over time, which is what almost everyone does.

Say you bought:

  • 10 shares at $50
  • 10 shares at $80
  • 10 shares at $110

Now you sell 10 shares at $120. Your proceeds are $1,200. But your gain is $1,200 minus the cost of the shares you sold — and you never labeled which ten those were. The method decides for you.

What is FIFO (first in, first out)?

FIFO assumes the first shares you bought are the first ones you sell. Sell 10 shares and you’re selling the $50 lot.

  • Cost basis: 10 × $50 = $500
  • Gain: $1,200 − $500 = $700

FIFO is the IRS default for stocks: if you cannot adequately identify which shares you sold, Publication 550 treats them as the shares you acquired first (IRS Publication 550, “Identification not possible”). In a stock that’s risen over time it tends to produce the largest taxable gain, because your oldest shares are usually your cheapest. The upside: those old shares are also the ones most likely to qualify for long-term treatment, which under Publication 550 means held more than one year, and long-term gains are typically taxed at a lower rate than short-term ones. So FIFO’s bigger gain sometimes comes at a friendlier rate.

What is LIFO (last in, first out)?

LIFO flips it: the most recent shares are the first ones sold. Sell 10 shares and you’re selling the $110 lot.

  • Cost basis: 10 × $110 = $1,100
  • Gain: $1,200 − $1,100 = $100

In a rising stock, LIFO usually produces the smallest gain today, because your newest shares are your most expensive. That defers tax — but watch the holding period. Those recent shares are more likely to be short-term, and short-term gains are generally taxed at your ordinary income rate, which can more than erase the benefit of the smaller gain. A small gain taxed at a high rate isn’t automatically better than a large gain taxed at a low one.

For US tax purposes, LIFO is not a separate method you elect for stocks. You get a LIFO result by specific identification: telling your broker which lot to sell at the time of the sale and receiving written confirmation, which is what Publication 550 calls an adequate identification. Many brokers let you set a standing lot-selection preference that does this for you.

What is the average cost method?

Average cost does what it says: add up everything you paid and divide by the number of shares.

  • Total paid: $500 + $800 + $1,100 = $2,400 for 30 shares
  • Average basis: $80 per share
  • Gain on 10 shares: $1,200 − $800 = $400

It’s the simplest to reason about and the hardest to game — every share costs the same blended amount, so you can’t cherry-pick a lot. For US taxes, though, it is not available for ordinary stock: Publication 550 allows the average basis method only for identical shares held with a custodian that are shares of a mutual fund or other regulated investment company (most US ETFs are RICs; grantor-trust and commodity ETPs and ETNs are not) or shares held in a dividend reinvestment plan (“Average Basis”). For an individual stock outside a DRIP, average cost is a useful way to read a position, not a basis you can report. The trade-off is exactly that lack of control: you give up the ability to choose high-basis lots to shrink a gain or low-basis lots to realize one deliberately.

Which cost basis method should you use?

The one the tax rules allow for that holding, chosen with the holding period in mind. There’s no universally “best” method — that’s the honest answer, and anyone who tells you otherwise is skipping the part that depends on your situation. But a few durable principles hold:

  • Consistency matters, and switching has rules. Specific identification is chosen sale by sale, but it has to be made at the time of the sale, not after the year ends. Average basis for fund shares is an election, and Publication 550 sets out when it can be revoked. Treat the choice as semi-permanent per position.
  • The holding period can outweigh the basis. A method that shows a smaller gain but converts it to short-term can cost you more than one that shows a larger long-term gain. Always look at gain and rate together.
  • It’s about timing, not magic. Cost-basis methods mostly shift when you pay tax, not whether you pay it. Deferring a gain has real value — but it’s a cash-flow advantage, not free money.

And the usual caveat, because it’s true: this describes US federal rules in general terms, situations vary, and it is education, not tax advice. For an actual filing decision, confirm the specifics with a professional who knows your circumstances.

Can software track cost basis for you?

Yes, and it should. The reason cost basis trips people up isn’t that the concept is hard — it’s that tracking it by hand across a dozen buys, in a spreadsheet you have to remember to update, is tedious and error-prone. That’s exactly the kind of arithmetic software should carry for you.

Tradune’s portfolio tracker computes cost basis using FIFO, LIFO, or average — your choice — so you can see realized and unrealized gains under each, kept current as you add to a position. Your broker’s Form 1099-B is still the record you file from; use the tracker to understand the numbers, and match its method to the one your broker applies. And if you just want to sanity-check a single sale, the cost-basis calculator will do the one-off math in a few seconds. Either way, what you get is a number you can trust — which is the whole point of tracking it at all.

Related guides

See this in your own portfolio

Tradune runs these numbers automatically across everything you hold.

Start free

Free for everyone right now · no card · nothing to buy