Tax Lot Optimization: Identification Methods and Wash Sale Traps

Tax lot optimization is the practice of choosing which specific shares to sell so the trade produces the smallest possible tax bill. Every purchase you make creates a separate tax lot with its own cost and holding period, and the lot you sell decides whether the gain is taxed at ordinary income rates up to 37% or at long-term rates of 0%, 15%, or 20%.1Internal Revenue Service. Topic No. 409, Capital Gains and Losses Most brokers sell your oldest shares by default, which is rarely the best answer. A few minutes spent picking the right lot can save thousands over the life of a portfolio.

Why the Lot You Sell Changes the Tax

Each time you buy shares of a stock, ETF, or mutual fund, your broker records the purchase date, the number of shares, and the price you paid. That price, plus fees and commissions, is the cost basis for that lot.2Office of the Law Revision Counsel. 26 U.S.C. 1012 – Basis of Property-Cost If you bought the same company three times over two years, you hold three lots, each with a different basis and a different age.

Two things about a lot drive its tax treatment. First is the gain, which is proceeds minus basis. Second is the holding period. Shares held one year or less produce short-term gains taxed as ordinary income, from 10% up to 37%. Shares held more than one year produce long-term gains taxed at 0%, 15%, or 20%.3Office of the Law Revision Counsel. 26 U.S.C. 1222 – Other Terms Relating to Capital Gains and Losses

The gap is large. A single filer in the 32% bracket who sells a short-term lot for a $10,000 gain owes $3,200. The same gain from a long-term lot at 15% costs $1,500. That $1,700 comes from lot choice alone.

Higher earners face an additional 3.8% surtax on investment income when modified adjusted gross income exceeds $200,000 for single filers, $250,000 for joint filers, or $125,000 for married filing separately.4Office of the Law Revision Counsel. 26 U.S.C. 1411 – Imposition of Tax At those income levels a long-term gain effectively costs 23.8% and a short-term gain at the top bracket reaches 40.8%. Most states then stack their own tax on top, so the all-in short-term rate can approach 50% in high-tax states.

The Identification Methods

Federal regulations recognize several ways to decide which lot is sold when you sell fewer shares than you own.5GovInfo. 26 CFR 1.1012-1 – Basis of Property – Section: Sale of Stock Each produces a different tax outcome from the same trade.

First-In, First-Out sells your oldest shares first. This is the default at most brokerages. FIFO usually produces long-term gains because the oldest shares are the most seasoned, but those shares often have the lowest basis, which means the biggest taxable gain.

Last-In, First-Out sells your newest shares first. The newest lots usually have a basis closer to today’s price, which can shrink the gain, but they are also more likely to be short-term.

Highest-In, First-Out sells the lot with the highest basis regardless of when you bought it. This tends to minimize the taxable gain and, in a down market, can produce a loss. HIFO is a reasonable standing default for a taxable brokerage account.

Specific identification lets you pick the exact lot. You get full control: choose the lot with the smallest gain, the biggest loss, or the right holding period for the situation. To use it, you have to tell your broker which shares to sell at the time of the trade and get written confirmation.6Internal Revenue Service. Publication 550, Investment Income and Expenses

Average cost is available for mutual funds and certain regulated investment company shares. It blends all your purchases into a single per-share basis. It’s simple, but it removes the ability to pick high- or low-basis lots. Once you use it, you’re locked in until you change methods in writing.

If you never choose, FIFO applies. Which means every unthinking trade uses the method that most often produces the largest taxable gain.

Choosing the Lot for the Trade in Front of You

The right lot depends on what the trade is for.

When you’re selling to raise cash and the position has appreciated, look for the lot with the highest basis. That produces the smallest gain. If two candidate lots produce similar gains, prefer the one that is already long-term, or the one whose short-term clock is closer to running out. Waiting a few weeks to cross the one-year line can shift a gain from ordinary rates to the 0/15/20 schedule.

When you’re harvesting a loss, look for the lot with the largest unrealized loss. If your portfolio has both short-term and long-term losses available on the same holding, the short-term loss is usually more valuable, because it will offset short-term gains that would otherwise be taxed at ordinary rates.

Take a simple example. You own 500 shares of the same stock in three lots: 200 shares at $50 bought two years ago, 150 shares at $80 bought six months ago, and 150 shares at $40 bought three years ago. The stock now trades at $60. Under FIFO your broker sells the $50 lot first, giving you a $2,000 gain. Under specific identification you sell the $80 lot instead, capturing a $3,000 short-term loss you can use against other gains.

How Losses Net at Year End

Losses and gains don’t drop into a single bucket. Short-term gains and losses net against each other first, and long-term gains and losses net against each other separately. If one category ends up net negative and the other net positive, those two results then offset. Excess losses deduct up to $3,000 against ordinary income each year ($1,500 if married filing separately), and any remainder carries forward indefinitely.7Office of the Law Revision Counsel. 26 U.S.C. 1211 – Limitation on Capital Losses The ordering is why matching a short-term loss to a short-term gain pays off more than letting it fall through to cancel a long-term gain that was already taxed at a lower rate.

Executing a Specific-Lot Sale

Before placing the order, open your account’s unrealized gain and loss view. It lists each lot with its purchase date, basis, market value, and short- or long-term status. Decide which lot you want to sell.

In the order entry screen, choose the option labeled “Specific Lot,” “Tax Lot,” or “Versus Purchase.” The exact label varies. You’ll see your lots with fields to allocate shares from each one. Assign the shares to the lot you picked and submit.

After the trade fills, save the confirmation. It should show which lot was sold, along with the basis and acquisition date. That confirmation is your evidence you used specific identification if the IRS ever questions the reported basis.

If you don’t want to think about lots on every trade, change your standing method to HIFO. It won’t always be optimal, but it’s better than FIFO for most taxable accounts, and you can still override it with specific identification on any single order.

The Wash Sale Rule Can Undo the Whole Thing

If you sell a lot at a loss and buy the same or a substantially identical security within 30 days before or after the sale, the loss is disallowed.8Office of the Law Revision Counsel. 26 U.S.C. 1091 – Loss From Wash Sales of Stock or Securities The window is 61 days in total, and it includes purchases by your spouse. The disallowed loss isn’t gone permanently; it adds to the basis of the replacement shares and is recovered when you sell them. But for the year in question, your harvested loss disappears.

Investors commonly sell one fund and buy a similar one to stay invested — an S&P 500 fund replaced with a total market fund, for example. The IRS has never published a bright-line test for “substantially identical,” so leave meaningful daylight between the two investments.

Lots You Should Think Twice Before Selling

Some lots in your account did not start with a purchase you made, and their basis rules make them unusually tax-efficient.

Shares you inherit generally take a basis equal to the fair market value on the date the prior owner died.9Office of the Law Revision Counsel. 26 U.S.C. 1014 – Basis of Property Acquired From a Decedent This step-up can erase decades of appreciation. Stock a parent bought at $10 that was worth $200 on the date of death gives you a $200 basis. Inherited lots are also treated as long-term regardless of how briefly you have held them. Before you sell an inherited lot, check whether you’d be better off selling a lot you bought yourself at a higher basis.

Gifts work differently. If the donor’s basis was below fair market value when they gave you the shares, you take their basis and their holding period (carryover basis).10Office of the Law Revision Counsel. 26 U.S.C. 1015 – Basis of Property Acquired by Gifts and Transfers in Trust If the donor’s basis was above fair market value at the time of the gift and you later sell for a loss, your basis for the loss calculation is the lower fair market value on the gift date. That dual-basis rule can leave a sale in a zone where it produces neither a reportable gain nor a deductible loss.

Reporting and Records

Your broker reports the basis, proceeds, and holding period for each sale to you and to the IRS on Form 1099-B, generally by February 15 of the year after the sale.11FINRA. Cost Basis Basics You reconcile those figures on Form 8949, and the totals flow to Schedule D of your Form 1040.12Internal Revenue Service. About Form 8949, Sales and Other Dispositions of Capital Assets

Older lots, inherited shares, and positions transferred between brokers are where problems show up. Your current broker may not have the right basis for shares purchased somewhere else, and the 1099-B may mark those as “basis not reported to IRS.” You are responsible for correcting the number on Form 8949. Keep original purchase confirmations, date-of-death valuations, and gift documentation in your own files. If you have transferred positions and never checked whether the basis migrated correctly, look now. Wrong numbers here mean either overpaying or underreporting, and the underreporting version comes with penalties.