A wash sale happens when you sell a stock at a loss and then buy the same or a substantially identical stock within 30 days

The IRS does not let you claim a tax loss on a stock sale if you buy back that stock (or one very similar to it) within 30 days before or after the sale. This rule is called the wash sale rule. If you trigger it, the loss you claimed disappears — the IRS adds it to the cost basis of the new shares you bought instead, which means you pay tax on a larger gain later or claim a smaller loss.

The 30-day window runs from 30 days before the sale through 30 days after the sale. So if you sell shares on June 15, you cannot buy the same stock from May 16 through July 15 without triggering the rule. The rule applies whether you buy the shares yourself or someone in your household does — spouses and dependent children count, but adult children do not.

This rule exists because the IRS wants to prevent people from harvesting losses for tax purposes while keeping the same economic position. You can still sell at a loss; you just cannot use that loss to reduce your taxable income if you immediately buy back in.

Key Takeaways

  • A wash sale occurs when you sell a stock at a loss and repurchase the same or substantially identical stock within 30 days before or after the sale.
  • If the IRS determines you triggered the wash sale rule, your loss does not disappear — it gets added to the cost basis of your new shares, deferring the tax benefit.
  • The 30-day period includes 30 days before the sale and 30 days after, so timing matters when you plan to reenter a position.
  • Substantially identical means the same company and class of stock; buying a similar but different stock (like a competitor) does not trigger the rule.
  • Your broker does not always catch wash sales automatically, so you need to track them yourself or use tax software that flags them.

What "substantially identical" actually means

The IRS rule bans repurchasing the same stock, but also anything "substantially identical." For individual stocks, this is fairly narrow: buying the same company's stock in the same class counts. If you sell shares of Apple common stock at a loss, you cannot buy Apple common stock back within the window. But if you buy Apple preferred stock instead, that is a different class and does not trigger the rule.

Where this gets tricky is with funds and options. If you sell a stock fund at a loss, buying a different fund that tracks the same index — say, switching from one S&P 500 fund to another — may trigger the rule because the holdings are substantially identical. The IRS has not published a definitive list of which funds count as substantially identical, so tax professionals often advise caution when swapping between similar funds.

Buying call or put options on the same stock, or buying the stock itself after selling covered calls, can also trigger the rule. The safest approach: if you want to stay invested in the same company or sector, wait 31 days after the sale before buying back, or buy something genuinely different in the meantime.

How the wash sale rule changes your taxes

When you trigger a wash sale, the loss you tried to claim does not vanish permanently. Instead, the IRS adds that loss amount to the cost basis of the new shares you bought. Your cost basis is what you paid for the shares — it determines your gain or loss when you eventually sell for real.

Here is a concrete example: you buy 100 shares of a stock for $5,000. It drops to $3,000, and you sell at a $2,000 loss. Within 30 days, you buy 100 shares again for $3,000. The wash sale rule applies. You cannot claim the $2,000 loss on this year's taxes. Instead, your cost basis in the new shares becomes $5,000 (the $3,000 you paid plus the $2,000 disallowed loss). If you sell those shares later for $4,000, your loss is only $1,000 instead of $1,000 — you have just deferred the tax benefit to a later year.

The rule can also affect how you calculate gains. If you buy back at a higher price than you sold, the disallowed loss still adds to your basis, which reduces your eventual taxable gain. The tax benefit does not disappear; it moves to whenever you finally exit the position without triggering another wash sale.

When your broker reports wash sales to the IRS

Your broker tracks your trades and reports them to the IRS on Form 1099-B. Starting in 2022, brokers have been required to identify wash sales on that form and adjust your cost basis accordingly. However, this requirement only applies to sales and repurchases within the same brokerage account at the same broker.

If you sell shares at Broker A and buy back at Broker B, your first broker may not catch the wash sale. The IRS can still identify it during an audit, but the burden falls partly on you to report it correctly on your tax return. Tax software like TurboTax and H&R Block now flag potential wash sales, but they rely on you entering all your trades accurately.

Even if your broker adjusts your cost basis automatically, you should verify it. Mistakes happen, especially if you have accounts at multiple brokers or if you trade frequently. When you file your taxes, your Form 1099-B should show the adjusted basis; if it does not match what you calculated, contact your broker to correct it before filing.

Strategies to avoid wash sales if you want to sell at a loss

If you want to claim a tax loss but stay invested in the same sector or company, you have a few options. The simplest is to wait 31 days after selling before buying back. During that month, you can buy a different stock in the same industry, or hold cash, or invest in a different asset class entirely.

Another approach is to buy a similar but not substantially identical investment. If you sell a single stock at a loss, you could buy an ETF that holds that stock plus others. If you sell a broad index fund at a loss, you could buy a different index fund that tracks a slightly different benchmark — though this is riskier because the IRS has not clearly defined the boundary. Consult a tax professional if you are considering this route.

Some investors use a "swap" strategy: sell the losing position, immediately buy a similar (but not identical) investment to stay in the market, and then buy back the original stock after 31 days. This keeps you invested while avoiding the wash sale rule. The tradeoff is that you may miss gains during the 31-day gap, or you may end up holding two positions temporarily.

Wash sales in retirement accounts and special situations

The wash sale rule does not apply inside retirement accounts like IRAs, 401(k)s, or Roth IRAs. You can sell a stock at a loss and buy it back immediately without triggering the rule. This is one reason some investors do their tax-loss harvesting in taxable accounts and hold long-term positions in retirement accounts.

However, if you have the same stock in both a taxable account and a retirement account, selling in the taxable account and buying in the retirement account within 30 days may still trigger the rule — the IRS considers accounts in your name as a single taxpayer unit. Spouses filing jointly have separate wash sale tracking, so one spouse can trigger a wash sale while the other does not.

If you inherit stock and sell it at a loss within 30 days of inheriting it, the wash sale rule still applies. The same goes for stock received as a gift — the rule does not care how you came to own the shares, only whether you sell and repurchase within the window.

Frequently Asked Questions

Does the wash sale rule apply if I sell at a gain instead of a loss?

No. The wash sale rule only applies to losses. You can sell a stock at a gain and buy it back immediately with no tax consequences from the wash sale rule. The rule exists to prevent people from claiming losses they do not really have, not to restrict gains.

What if I sell a stock and my spouse buys it back within 30 days?

The wash sale rule applies. If you are married and file jointly, the IRS treats both of your accounts as a single unit for wash sale purposes. Your spouse buying back within 30 days triggers the rule just as if you had bought it yourself. This does not apply to adult children or other relatives.

Can I claim the loss if I wait exactly 31 days to buy back?

Yes. The wash sale rule covers 30 days before and after the sale. If you sell on June 15 and buy back on July 16 (32 days later), you are outside the window and can claim the loss. Many investors use a calendar to track this precisely, especially when they are close to the boundary.

What happens if I did not know about the wash sale rule and already triggered it?

You can still correct it when you file your taxes. If your broker did not catch it and you claimed the loss, the IRS may disallow it during an audit. If you catch it before filing, you can amend your return to remove the loss and adjust your basis. It is better to fix it yourself than to wait for the IRS to find it.

Does selling covered calls on a stock trigger a wash sale?

Selling a covered call on a stock you own does not trigger a wash sale by itself. But if you sell the stock at a loss and then sell a call on the same stock within 30 days, or if you buy the stock back to cover a call you sold, the rule may apply. The IRS views these as related transactions. Consult a tax professional if you use covered calls and want to harvest losses.