The Wash Sale Rule: 30 Days, IRAs, Spouses and Other Traps
TL;DR: Sell at a loss and buy the same or a substantially identical security within 30 days before or after, and the loss is disallowed for now. It is added to the new shares' basis, except when the repurchase happens in an IRA, where the loss can be lost for good.
Educational only, not tax, legal, or investment advice. Examples are illustrations, not predictions. Rules and limits change; verify current figures and talk to a qualified professional about your situation.
Tax-loss harvesting is one of the few free lunches in investing: sell a position that is down, book the loss for tax purposes, and stay invested in something similar. The wash sale rule is the restaurant's fine print. It stops you from claiming a loss when you have not really changed your position.
The rule lives in Section 1091 and is simple to state and surprisingly easy to trip over, especially with automatic dividend reinvestment, multiple accounts and a spouse who also invests. This guide explains the 61-day window, what "substantially identical" means, the IRA and spouse traps, basis adjustments and several examples. For context see capital gains tax planning and the tax planning guide.
CPA Warning Label: The wash sale rule is the IRS saying: nice try, but you cannot sell your cake, claim a loss on it and eat it 12 minutes later.
61-day window
A wash sale happens when you sell or trade stock or securities at a loss and, within 30 days before or after the sale, you:
- buy substantially identical stock or securities,
- acquire them in a fully taxable trade,
- acquire a contract or option to buy them, or
- acquire them for your IRA or Roth IRA.
Thirty days before, the sale day, and thirty days after make a 61-day window. Purchases before the sale count too, which surprises people who bought a second lot "to average down" two weeks before selling the first lot at a loss.
What happens to the loss
In most cases the loss is not gone; it is deferred. The disallowed loss is added to the basis of the replacement shares, and the holding period of the sold shares carries over. When you later sell the replacement shares in a non-wash transaction, you get the loss back through the higher basis.
What the rule does not cover
- Gains. Selling at a gain and buying back immediately is fine, and is the basis of gain harvesting.
- Different securities. Swapping one company's stock for a competitor's is not a wash sale.
- Crypto, as of October 2026. Section 1091 applies to stock and securities. Most crypto is treated as property, not a security, for this purpose. Congress has proposed extending the rule, so check current law before relying on this.
Partial wash sales
If you sell 100 shares at a loss and buy back 40 within the window, only the loss on 40 shares is disallowed. The other 60 shares' loss is allowed.
Substantially identical
The IRS has never published a bright-line definition. The general principles:
- Same company's common stock: substantially identical.
- Same company's bonds or preferred stock: usually not, unless convertible and trading like the common.
- Two different companies: not substantially identical, even in the same industry.
- Options to buy the same stock: covered explicitly.
- Two mutual funds or ETFs tracking the same index from different sponsors: a gray area. Many investors and advisers treat them as not substantially identical because they have different holdings weights, expenses and structure, but there is no official IRS ruling saying so.
- Different share classes of the same fund, or an ETF share class of a mutual fund: higher risk of being treated as identical.
Safer swaps
The cautious approach to tax-loss harvesting is to swap into a fund with a different underlying index, such as a total market fund for an S&P 500 fund, or a large-cap value fund for a large-cap blend fund. The portfolio exposure stays similar, and the argument that the funds are substantially identical is weak. Choosing between funds is covered in the index fund comparison guide.
IRA and spouse purchases
The IRA trap
In Revenue Ruling 2008-5, the IRS ruled that if you sell stock at a loss in a taxable account and your IRA or Roth IRA buys substantially identical stock within the window, the loss is disallowed. Worse, the basis of the IRA shares does not increase, because IRA assets have no separate basis for this purpose. The loss is permanently lost, not deferred.
This happens most often by accident: automatic contributions or dividend reinvestment in a retirement account buy the same fund you just sold at a loss in your taxable account. Many brokers do not track wash sales across accounts, so the 1099-B will not catch it. You are still responsible.
The spouse trap
Publication 550 says a wash sale applies if your spouse buys substantially identical stock, and also if a corporation you control does. If you sell at a loss and your spouse buys the same fund in their account within 30 days, it is a wash sale. Married couples should coordinate harvesting.
Workplace plans
Whether 401(k) purchases trigger the rule is less clear because the ruling addressed IRAs. Many practitioners treat it conservatively and avoid buying the same fund in a 401(k) within the window.
Dividend reinvestment
A dividend reinvested 10 days after a loss sale is a small purchase that can disallow a small part of the loss. Turn off reinvestment on positions you plan to harvest, at least during the window.
Basis adjustment
When a wash sale defers a loss in a taxable account, two adjustments follow:
- Basis. Add the disallowed loss to the cost of the replacement shares.
- Holding period. Add the holding period of the sold shares to the replacement shares.
Brokers report wash sales they detect in the same account on Form 1099-B (box 1g). On Form 8949, you report the sale and enter the disallowed loss as an adjustment with code W. If the wash sale crossed accounts or brokers, you need to make the adjustment yourself based on your records.
Year-end trap
A loss sold in late December and repurchased in early January is still a wash sale. The loss is disallowed for the year and pushed into the replacement shares. If you are counting on a December loss to offset gains, keep the replacement out of the window or pick a different security.
Examples
Illustration 1: classic deferral
Taylor buys 100 shares of Fund A for $10,000. It drops to $8,000, and Taylor sells on November 1, 2026 for a $2,000 loss. On November 20 Taylor buys 100 shares of Fund A for $8,200. The $2,000 loss is disallowed. The new shares' basis becomes $8,200 + $2,000 = $10,200, and their holding period includes the time Taylor held the original shares. If Taylor sells them in March for $9,000, the reportable loss is $1,200.
Illustration 2: the clean swap
Taylor sells Fund A (an S&P 500 index fund) at a $2,000 loss and immediately buys Fund B, a total U.S. stock market fund. The loss is allowed in 2026, Taylor stays invested in U.S. stocks, and the new basis is simply the cost of Fund B.
Illustration 3: the IRA accident
Jordan sells Fund A at a $5,000 loss in a taxable account on December 5. On December 15, Jordan's Roth IRA automatically buys Fund A with a scheduled contribution. Under Rev. Rul. 2008-5, the loss on the shares matched by the Roth purchase is disallowed, and the Roth IRA's shares get no basis increase. If the Roth bought enough shares to match the full sale, the entire $5,000 loss is gone permanently.
Illustration 4: the spouse
Chris sells 200 shares of a stock at a $3,000 loss on June 1. Pat, Chris's spouse, buys 200 shares of the same stock on June 20 in a separate brokerage account. The loss is disallowed and added to the basis of Pat's shares.
Checklist before harvesting
- Look back 30 days for purchases in all accounts, including spouse and IRAs.
- Turn off dividend reinvestment and automatic investments in that security for the window.
- Pick a replacement that tracks a different index.
- Calendar the 31st day if you want to switch back.
- Keep records of any cross-account adjustments for Form 8949.
Loss harvesting also shows up in odd places on this site, such as planning around the 4% rule in down markets and an installment sale of a rental, where losses can offset recognized gain.
FAQ
How long do I have to wait to buy back after a wash sale?
Wait until at least the 31st day after the sale, and make sure you did not buy substantially identical shares in the 30 days before the sale either. The window is 61 days in total.
Does the wash sale rule apply to IRAs?
Yes. If your IRA or Roth IRA buys substantially identical securities within the window, the loss in your taxable account is disallowed, and under Rev. Rul. 2008-5 the IRA gets no basis increase, so the loss is lost.
Are two S&P 500 funds from different companies substantially identical?
There is no official IRS rule. Many investors treat them as different, but the safer approach is to switch to a fund tracking a different index.
Does the wash sale rule apply to crypto?
As of October 2026, Section 1091 applies to stock and securities, and most crypto is treated as property rather than a security. Proposals to extend the rule exist, so check current law.
Does the wash sale rule apply if I sell at a gain?
No. It only applies to losses. You can sell at a gain and repurchase immediately.
Sources & fact-check notes
- 26 U.S.C. 1091 (wash sales) (accessed 2026-10-27)
- IRS Rev. Rul. 2008-5 (wash sale via IRA) (accessed 2026-10-27)
- IRS Publication 550, Investment Income and Expenses (accessed 2026-10-27)
Figures checked October 27, 2026. Rules and limits change; verify with the official source before acting.