Save on Taxes by Understanding FIFO or LIFO

FIFO and LIFO are two widely used methods for calculating capital gains. Understanding the differences between them can help you save on taxes. How much can you save? Up to 25% of your capital gains if you live in a country with high tax rates. While savings are typically less than this, they can still be significant. How does this work? By applying portfolio optimization techniques that reduce your tax liability or defer tax payments. However, to optimize effectively, you need to understand how your broker calculates capital gains.

I assume you are a long-term investor who periodically adds shares (stocks, ETFs, cryptocurrencies) to your portfolio and later reduces your holdings by selling shares at different prices. Choosing which shares to sell or selecting a specific calculation method can make a substantial difference in the taxes you owe. If you are an occasional investor who buys and sells all shares in a single transaction, this optimization won't benefit you. Short-term investors (those who gamble or speculate) also won't find this strategy useful. If your country of residence has no capital gains tax or complex tax laws, you may not need this approach or may need to consider additional constraints.

FIFO vs LIFO: Capital Gain Calculation

When it comes to calculating taxes on capital gains, several methods are used. Among them are FIFO and LIFO, which I described in earlier posts. The good news is that choosing the right method can provide significant tax benefits. Let's examine the following example:

FIFO and LIFO tax schema

You bought 5 shares for $10 each and then purchased another 5 shares of the same company for $12 each. After some time, you decided to sell half your shares. The market price is $12 per share. Should you sell the shares bought for $10 or $12 each? Using the FIFO method, you would sell the shares purchased at $10, resulting in a $10 pre-tax gain. With the LIFO method, you would sell the shares bought at $12, which generates no profit, so you pay no tax.

But isn't it better to use FIFO and realize a profit even if you pay tax? The answer depends on your situation. First, FIFO and LIFO do not affect your account balance. In both scenarios, you receive the same amount of money ($60 from selling 5 shares at $12) and still own 5 shares. The calculation method only impacts taxation. Using FIFO means you pay tax in the current year, while LIFO defers the tax payment. You will pay the same total tax amount unless short-term and long-term capital gains are taxed differently.

You can calculate this yourself using our tool—just click on the link to copy the following data into TransCalc, where you can calculate taxes using both LIFO and FIFO methods.

2020-06-29-13.14.01;equity;B;5;10
2020-06-30-13.14.01;equity;B;5;12
2020-07-01-09.32.05;equity;S;5;12

What if you have no choice and the calculation method is imposed? You can still find opportunities for optimization.

Saving on Taxes with FIFO

Consider the following scenario:

FIFO scenario

You bought 10 shares of equity at $5 per share. The price rose, and when it reached $10, you bought another 10 shares. You now hold 20 shares with a total investment of $150 and an average price of $7.50 per share. However, the price dropped shortly after your second purchase. To avoid further losses, you sold 10 shares for $7 per share. You incurred a real loss of $30, but on paper, you gained $20—because the initial 10 shares bought at $5 are now worth $7. Your net paper loss is:

-$30 (real loss) + $20 (paper gain) = -$10.

You may be disappointed, but the more frustrating part is that you still owe tax. According to FIFO calculations, you made a gain. Why? When selling (First Out), you sold the shares bought first (First In). Your taxable gain is:

10 × ($7 - $5) = $20.

You have a losing position yet still owe tax. What went wrong? Two key issues:

  1. You timed your purchase poorly by buying at the peak.
  2. You only liquidated a portion of your position—the part that was profitable under FIFO.

If you had sold your entire position, your paper loss would become a real loss, which is tax-exempt. If you want to maintain your position, you can repurchase the shares later. However, the best strategy in this situation is to sell an amount that nullifies your gain or loss. This reduces transaction costs while allowing you to keep some shares if the price rebounds. Aim for a gain/loss as close to $0 as possible. Let's calculate how many shares to sell: selling all shares from your first transaction gives a $20 paper gain. To offset this, sell shares from your second transaction, which have a $3 loss per share. The optimal amount is 7 shares:

$20 (gain) - 7 × $3 (loss) = -$1.

Now you owe no tax and still hold shares. Sounds simple? It's not—optimization becomes complicated when:

  1. You have numerous buy and sell transactions.
  2. Gains are calculated using different rules (e.g., LIFO, average cost).
  3. Tax laws impose constraints, such as required holding periods between selling and repurchasing shares.

That's why it's better to use a spreadsheet or dedicated tool for these calculations. I've created TransCalc, a free calculator for capital gains and taxes.

Saving on Taxes with LIFO

Suppose you bought shares, and after a few months, the price dropped. You held onto your shares and even bought 10 more, totaling 20 shares. The price hit a bottom and began to rise. You decided to sell half your position—10 shares—at a price below your average cost. Overall, you still haven't broken even, but under FIFO, you would have a taxable gain!

Meta FIFO and LIFO are methods for calculating capital gains. Understanding the differences between them allows you to save on taxes.