Skip to content
Investing

How tax-loss harvesting works within the IRS wash sale rule

Selling losing investments for tax deductions requires understanding the 30-day window that blocks claiming losses if you buy back similar securities.

Exterior of the New York Stock Exchange building with classical columns and surrounding high-rise buildings.
The New York Stock Exchange, located at 11 Wall Street in Lower Manhattan.Ken Lund from Reno, Nevada, USA · CC BY-SA 2.0 · via Wikimedia Commons

Tax-loss harvesting—selling investments that have declined to lock in a loss for tax purposes—is a standard strategy for reducing taxable investment income. By offsetting capital gains with capital losses, investors in higher tax brackets can substantially lower their overall tax bills. But the strategy only works if you follow the wash sale rule, an IRS restriction that disallows losses under specific circumstances.

The rule prevents you from selling an investment at a loss and then buying it back immediately. Understanding when you can rebuy, and what securities count as "the same," determines whether harvesting actually saves you money or simply shifts the loss forward. The strategy also matters only for investors holding securities in regular taxable accounts—it provides no benefit in tax-sheltered accounts like 401(k)s and traditional IRAs, which already shield investments from annual capital gains taxes.

How tax-loss harvesting reduces your tax bill

Tax-loss harvesting works by matching losses against gains. When you sell an investment that has gained in value—whether a stock, mutual fund, or exchange-traded fund—that gain is taxable income. But if you simultaneously sell another investment at a loss, you can offset the gain dollar-for-dollar. The net effect reduces or eliminates the tax owed on the gain. For investors in higher tax brackets, where the federal capital gains tax rate reaches 20 percent, the savings can be substantial.

The strategy offers a secondary benefit: portfolio rebalancing. When you sell a losing position, you free up cash that can be redeployed into investments that better align with your target asset allocation. This allows you to both reduce taxes and improve your portfolio's structure in a single transaction. Because the strategy works only within taxable accounts, it does not apply to 401(k)s, traditional IRAs, Roth IRAs, or other tax-advantaged retirement accounts where gains and losses are already sheltered from annual taxation.

The wash sale rule and the 30-day window

According to IRS Publication 550, you cannot deduct a loss on a security sale if you "purchase a substantially identical security within 30 days before or after the sale." The rule applies in both directions—the restricted period runs 30 days before the sale date and 30 days after it. This creates a 61-day window during which purchasing a similar security will disqualify your loss. If you sell a losing position on January 15, for example, you cannot buy a substantially identical security from December 16 (30 days before) through February 14 (30 days after).

The consequence of violating the rule is not a penalty or audit, but a permanent alteration to your tax basis. If you sell at a loss but repurchase substantially identical property within the 30-day window, the IRS disallows your loss deduction. Instead, the disallowed loss amount is added to your cost basis in the newly purchased security. This means the loss is not eliminated—it is deferred. When you eventually sell the new purchase at a later date, your higher basis will reduce the gain (or increase the loss), essentially allowing you to claim the original loss in a future year.

What counts as substantially identical

According to IRS Publication 550, in determining whether securities are substantially identical, "you must consider all the facts and circumstances in your particular case." The definition is not bright-line; instead, the IRS requires examination of specific facts and circumstances. Identical shares in the same stock or fund clearly meet the definition. Two units of the same mutual fund obviously are substantially identical. But the rule's application to similar but different securities is less certain.

However, the IRS notes that stocks or securities from different corporations are ordinarily not considered substantially identical, though they may be in some cases. The exact boundaries depend on the specific facts and circumstances of each situation.

“The 30-day window extends 30 days in both directions—30 days before the sale and 30 days after—requiring a 61-day total wait if you want to repurchase the same investment and claim the loss.”

Strategies for harvesting while managing timing

Effective tax-loss harvesting requires either waiting out the 30-day period or temporarily purchasing a genuinely different investment. If you hold an S&P 500 index fund that has declined in value, you could sell at a loss and immediately buy a broad-market fund tracking a different index, such as the total U.S. stock market index or an international fund. After 31 or more days have passed, you can rotate back to your original S&P 500 fund without triggering the wash sale rule. This keeps your market exposure roughly constant while allowing you to deduct the loss for the current tax year.

The strategy requires planning around the year-end deadline. All harvesting must occur before December 31st—there is no grace period for wash sale compliance. The 30-day window extends into the following year, which is why losses harvested in late December may prevent repurchases until January or beyond. Some investors coordinate their harvesting schedule with quarterly portfolio rebalancing to maximize efficiency and avoid holding unintended positions for extended periods.

Limitations and when harvesting matters most

Tax-loss harvesting is most valuable for investors with substantial capital gains to offset—those who have sold appreciated securities during the year or who hold a concentrated position in a single stock that has grown significantly. For investors with modest portfolios or those who experience gains and losses in roughly equal amounts year to year, the strategy offers less benefit.

The timing requirement also limits applicability. An investor cannot harvest losses in December and immediately repurchase the same investment in January without forfeiting the deduction. The wait creates a period of market exposure risk; an investor might miss gains during the 31-day window between selling and repurchasing. Additionally, the strategy assumes you have investment losses to harvest. Investors in conservative portfolios with stable, long-term holdings may rarely encounter underwater positions worth selling. The strategy also works only in taxable accounts—it provides no tax benefit in 401(k)s, IRAs, or other sheltered accounts where tax liability does not depend on annual trading activity.

Related coverage: How New York Taxes Stock Compensation; What A High Income Actually Costs In New York.


Related