The Wash-Sale Rule
Last updated July 2026
Short answer
The wash-sale rule is an IRS rule that disallows a loss if you buy the same or a substantially identical security within 30 days before or after the sale, a 61-day window centered on the sale date. The loss is not gone: it gets added to the cost basis of the replacement shares, so the benefit is deferred until you sell those. It reaches across all your accounts, including your IRAs and, in many cases, a spouse's account, which is why you cannot dodge it by rebuying in a different account. "Substantially identical" means the same stock or fund; two broad-index ETFs tracking different indexes are generally not identical, but that is a genuine gray area. The rule applies only to losses, not gains, and it is the main constraint on tax-loss harvesting. This is general information, not tax advice; consult a tax professional.
The wash-sale rule is the trap that quietly voids a tax loss you thought you had captured. It is short in the tax code but wide in reach, and misunderstanding it is one of the most common ways well-intentioned tax-loss harvesting backfires. This guide explains exactly how the rule works: the 61-day window, what triggers it, how a disallowed loss is deferred rather than destroyed through a basis adjustment, its surprising reach across your accounts and even your spouse's, what "substantially identical" does and does not mean, and the fact that it applies only to losses. It is descriptive and educational, not tax advice.
What the rule says and why it exists
The wash-sale rule disallows a loss on the sale of a security if, within 30 days before or after that sale, you buy the same or a substantially identical security. The purpose is straightforward: without it, an investor could sell a holding purely to claim a paper loss for tax purposes and then instantly rebuy the identical position, capturing the deduction while never really changing their exposure. The rule closes that door by refusing the loss when you effectively stay in the same investment.
It matters most in the context of tax-loss harvesting, where the entire goal is to realize a loss while staying invested. The wash-sale rule is what forces harvesters to use a replacement that is similar but not substantially identical, rather than simply rebuying what they sold. Understanding it is therefore the prerequisite for harvesting correctly. This is general information, not tax advice.
The 61-day window: before and after
The timing is the part people most often get wrong. The rule covers 30 days before the sale and 30 days after it. Counting the day of the sale itself, that is a 61-day window. Most investors remember the "after" half and carefully wait past 30 days to rebuy, but forget the "before" half: if you bought additional shares of the security shortly before selling other shares at a loss, that earlier purchase can trigger the rule just as easily.
A frequently missed trigger is automatic dividend reinvestment. If a fund reinvests a dividend into new shares inside the window, even a small amount, it can create a wash sale on part of your loss without you doing anything deliberately. The same goes for recurring automated buys. Because of the before-and-after span and these automatic purchases, careful harvesters avoid buying the same or a substantially identical security anywhere in the full 61-day window. Verify the mechanics with a tax professional.
The loss is deferred, not lost: the basis adjustment
A crucial and reassuring detail: a disallowed wash-sale loss is not forfeited. Instead, the amount of the disallowed loss is added to the cost basis of the replacement shares you bought. Your holding period from the original shares also carries over to the replacement. So the tax benefit is not erased; it is deferred until you eventually sell the replacement shares, when the higher basis reduces your gain or enlarges your loss.
A quick example: you buy a stock at 100 dollars, sell at 70 dollars for a 30 dollar loss, then rebuy within the window at 72 dollars. The 30 dollar loss is disallowed now, but it is added to the replacement's basis, making it 102 dollars rather than 72. When you later sell that replacement, the built-in 30 dollars flows through. The one important exception: if the replacement is bought inside an IRA, the basis benefit generally cannot be recovered, so that loss can be permanently lost. This is educational, not tax advice.
It reaches across your accounts, including IRAs and a spouse's
The wash-sale rule does not stop at a single account. The IRS looks at all of your accounts together, so selling a stock at a loss in your taxable brokerage account and buying the same security in your IRA within the window can trigger the rule. As noted above, a replacement purchased in an IRA is the worst case, because the loss cannot be restored through a basis adjustment there, so it is effectively gone.
The reach extends further: the IRS generally treats a purchase by your spouse, or by a corporation you control, as if you made it for wash-sale purposes. This means a household cannot sidestep the rule by having one spouse sell and the other buy. This wide scope is exactly why harvesting requires looking at your entire financial picture, not just the account where you placed the sale. Because these cross-account situations get intricate, confirm any specific case with a tax professional.
What substantially identical means
The phrase "substantially identical" is the heart of the rule and, frustratingly, the IRS has never defined it precisely, which makes it a genuine gray area. Some cases are clear: the exact same stock is substantially identical to itself, and the same mutual fund or ETF is substantially identical to itself. Options and contracts to acquire the same security can also count. Selling and immediately rebuying the identical ticker is the textbook wash sale.
The harder question is funds. Two broad-market ETFs from different providers that track different underlying indexes are generally treated as not substantially identical, which is why harvesters swap between them. But two funds tracking the same index are far riskier, and there is no bright-line safe harbor for funds, so this remains a judgment call. Individual stocks of two different companies, even close competitors, are not substantially identical. Because the answer depends on specifics and is genuinely a tax-advice question, confirm any particular swap with a tax professional before relying on it.
It applies only to losses, not gains
One clarifying point that removes a lot of confusion: the wash-sale rule applies only to losses. If you sell a security at a gain and rebuy it immediately, the rule is simply irrelevant, the gain is taxable as normal, and nothing is disallowed. The entire machinery exists to prevent claiming a tax loss while staying in the same position, so a profitable sale is outside its scope.
This is worth knowing because it explains why a related strategy, sometimes called tax-gain harvesting (realizing gains on purpose in a low-income year and rebuying), is not restricted by the wash-sale rule, since there is no loss to disallow. For how gains themselves are taxed and the levers around them, see how to reduce investment taxes. This is general information, not tax advice.
The wash-sale rule at a glance
| Element | How it works |
|---|---|
| The window | 30 days before and 30 days after the sale, a 61-day span counting the sale date |
| What triggers it | Buying the same or a substantially identical security inside that window (including reinvested dividends and options) |
| The consequence | The loss is disallowed for now, not lost: it is added to the cost basis of the replacement shares |
| Scope | Applies across all your accounts, including IRAs and, in many cases, a spouse's account; applies only to losses, not gains |
Put together, the rule is narrow in what it targets (a loss where you rebought the same or a substantially identical security in the 61-day window) but broad in reach (all your accounts, including IRAs and a spouse's) and forgiving in outcome (the loss is deferred into the replacement's basis rather than destroyed, except inside an IRA). It applies only to losses. The gray zone is what counts as substantially identical, especially for funds, so verify current guidance and treat this as a framework, not tax advice. Confirm any specific situation with the IRS or a licensed professional.
Where Walnut fits
The wash-sale rule is hard to police by hand precisely because it spans every account you and your household hold: to spot a risk you have to see all your positions and recent buys in one place, not one brokerage at a time. That is a question about your real, cross-account holdings, which is where an AI assistant that reads across your accounts helps as context. Walnut, an AI investing app, lets you connect any major US broker, then chat in plain words through Claude, ChatGPT, or its built-in AI to see which holdings you own across accounts and which are below what you paid. It surfaces that context only: it does not track wash sales, calculate cost basis, execute trades on its own, or judge whether two funds are substantially identical. Walnut is not a registered investment adviser or a tax adviser, it does not calculate your taxes, and it does not tell you what to buy or sell.
Try Walnut on top of your broker
Walnut connects your accounts, then helps you see your holdings across accounts and which are below what you paid, by chatting through Claude, ChatGPT, or its built-in AI. Walnut does not track wash sales or calculate cost basis, is not an investment adviser or a tax adviser, and does not tell you what to buy or sell.
FAQ
What is the wash-sale rule?
The wash-sale rule is an IRS rule that disallows a loss on a sale if you buy the same or a substantially identical security within 30 days before or after that sale. The point is to stop investors from claiming a tax loss while effectively keeping the same position. The disallowed loss is not erased: it is added to the cost basis of the replacement shares, so the benefit is deferred rather than lost. This is general information, not tax advice.
How long is the wash-sale window?
The window runs 30 days before the sale and 30 days after it, which together with the sale date is a 61-day span. Many people forget the before half: buying more of a security shortly before you sell part of it at a loss can trigger the rule just as buying after can. To be safe, harvesters generally avoid buying the same or a substantially identical security anywhere in that 61-day window. Verify the mechanics with a tax professional.
What does substantially identical mean?
Substantially identical is not precisely defined by the IRS, which is why it is a gray area. The same stock or the same fund is clearly substantially identical. Two different broad-index ETFs that track different underlying indexes are generally treated as not substantially identical, though there is no bright-line rule for funds. Options and contracts to acquire the same security can also count. Because it is judgment-based, confirm any specific case with a tax professional.
What happens to a disallowed wash-sale loss?
It is deferred, not lost. When a loss is disallowed, the amount is added to the cost basis of the replacement shares you bought, and their holding period is adjusted to include the time you held the original shares. So when you eventually sell the replacement, the higher basis reduces your gain or increases your loss, giving you the benefit later. The one exception is a replacement bought inside an IRA, where the benefit can effectively be forfeited.
Does the wash-sale rule apply across accounts and to my spouse?
Yes. The rule looks across all of your accounts, so selling a stock at a loss in your taxable brokerage account and buying it in your IRA within the window can trigger it, and a buy in an IRA can permanently cost you the loss. The IRS also generally treats a purchase by your spouse, or by a company you control, as yours for this purpose. This wide reach surprises many people, so plan around all accounts and consult a tax professional.
Does the wash-sale rule apply to gains?
No. The wash-sale rule applies only to losses. If you sell a security at a gain and rebuy it immediately, the rule does not apply and the gain is simply taxable as usual. The rule exists specifically to prevent claiming a tax loss while keeping the same position, so it has nothing to say about profitable sales. This is educational information, not tax advice.
How do investors avoid a wash sale when harvesting losses?
The common approach is to buy a similar but not substantially identical replacement, for example swapping one broad US stock index fund for another that tracks a different index, so exposure barely changes without triggering the rule. Harvesters also watch for automatic dividend reinvestment, which can quietly buy shares inside the window, and avoid rebuying in any account, including an IRA or a spouse's. Because substantially identical is a judgment call, confirm with a tax professional.
Does Walnut track wash sales for me?
No. Walnut does not track wash sales, calculate cost basis, execute trades on its own, or give tax advice, and it is not a registered investment adviser or a tax adviser. It can read your connected accounts so you can see which holdings you own across accounts and which are below what you paid, useful context for a conversation with a tax professional. Any wash-sale determination and its basis effects should be confirmed with a licensed professional.
From here, see how the rule shapes tax-loss harvesting, the basis mechanics behind the deferral in cost basis, and the broader menu of levers in how to reduce investment taxes.
Walnut is informational and is not a registered investment adviser or a tax adviser. This page explains the wash-sale rule; it is not a recommendation to buy, sell, or hold any security or fund, and it is not tax advice. Investing involves risk, including the possible loss of principal, and past performance does not indicate future results. Tax rules change and depend on your individual circumstances, and terms like substantially identical are judgment-based; verify current guidance with the IRS or a licensed professional before making any decision. Do your own research or consult a licensed financial or tax professional.