The Wash-Sale Rule, Explained (and How to Harvest Losses Without Tripping It)
Selling at a loss to lower your tax bill only works if you avoid a rule that spans every account you own, including your spouse's and your IRA.

What the wash-sale rule actually says
The wash-sale rule lives in Section 1091 of the Internal Revenue Code. In plain English, it says you cannot deduct a loss on a security if you buy a substantially identical security within 30 days before or 30 days after the sale that produced the loss. Count both directions plus the day of the sale, and you get a 61-day window. Sell at a loss on day zero, and any repurchase from 30 days earlier through 30 days later can disallow that loss.
The reason the rule exists is simple. Congress did not want people selling a stock purely to book a tax loss and then buying it right back so their real position never changed. The loss looks real on paper, but economically you never left the trade. Section 1091 closes that door by refusing the deduction when you are effectively still holding the same thing.
One note before we go further. This is education, not tax advice. The rules below are accurate as of 2026, but your situation has details a general article cannot see, so confirm the specifics with a qualified tax professional before you act.
What 'substantially identical' really means
The phrase that trips people is substantially identical. The IRS has never published a bright-line list, but the settled reading is clear at the edges. Selling shares of a company and rebuying the same company's shares is substantially identical. Selling one S&P 500 index fund and rebuying a different S&P 500 index fund that tracks the same index is widely treated as substantially identical too, because you are holding the same basket by another name.
What is generally not substantially identical is a different company, or a fund that tracks a different index or a meaningfully different basket. Selling one large-cap fund and buying a total-market fund from another provider is a common harvesting move because the holdings and the benchmark differ. The gray zone is real, and options, warrants, and convertible securities on the same underlying can pull you back in. When you are unsure, the safe read is to assume closeness triggers the rule.
The loss is deferred, not destroyed
A wash sale in a taxable account does not vaporize your loss. It moves it. The disallowed loss is added to the cost basis of the replacement shares you bought, and the holding period of the shares you sold carries over to the new ones. So if you sold at a 2,000 dollar loss and that loss is disallowed, your replacement shares carry 2,000 dollars of extra basis. When you eventually sell those replacement shares in a clean transaction, the deferred loss comes back to you.
This is why a wash sale in a normal brokerage account is an inconvenience more than a catastrophe. You lose the deduction this year, but you keep it for later, and your holding period is protected. The problem is timing. Tax-loss harvesting is valuable precisely because you want the deduction now, to offset gains or income in the current year. A wash sale pushes that benefit into an unknown future, which defeats the point of harvesting in the first place.
The window spans every account you own, including your spouse's
Here is the part most people miss. The wash-sale rule is not scoped to a single brokerage account. It follows you across all of your accounts, and the IRS treats you and your spouse as one taxpayer for this purpose. Sell a stock at a loss in your taxable account at one broker, then buy it back in your account at another broker, or in your spouse's account, and you can still trigger a wash sale. Your IRA counts too.
This is where the rule becomes genuinely hard to track by hand. A single household might hold a taxable account at one firm, a Roth IRA at another, a rollover somewhere else, and a spouse's accounts on top of that. No single broker sees the whole picture. Your broker will flag a wash sale inside its own walls, but it has no idea what you bought in an account it cannot see. The rule applies anyway, and the responsibility to get it right is yours.
The IRA trap: a wash sale in a retirement account is forever
The most expensive mistake is triggering a wash sale with a purchase inside an IRA. Under Revenue Ruling 2008-5, if you sell a security at a loss in your taxable account and buy a substantially identical one in your traditional IRA or Roth IRA within the 61-day window, the loss is disallowed, and, critically, you get no basis step-up to recover it later.
The reason is mechanical. Normally the disallowed loss attaches to the basis of the replacement shares. But shares held inside an IRA have no outside cost basis that would ever produce a taxable benefit. So the deferred loss has nowhere to land. It is not postponed, it is gone. This is the one wash-sale outcome that is truly permanent, and it is easy to trigger by accident when an automatic reinvestment or a routine IRA buy happens to land on the same security you just sold at a loss.
How to harvest a loss without tripping the rule
The manual playbook has a few moves. The cleanest is to sell the losing position and wait 31 days before rebuying the same security, so no purchase falls inside the window. The cost is 31 days of exposure risk, and the market can move against you in that time. A second move is to sell and immediately buy a similar but not substantially identical replacement, so you stay invested in the same theme without holding the same basket. After 31 days you can switch back if you want.
Whichever path you take, three things have to be true at once. No substantially identical buy in the 61-day window, in any account, by you or your spouse, and nothing landing in an IRA. Holding all of that in your head across several brokers, dividend reinvestments, and a spouse's activity is exactly where harvesting goes wrong. The rule itself is not complicated. Seeing every account at the same time is the hard part.
How AI for investing does this in one pass
This is the kind of problem where seeing everything at once changes the answer. Tengu is AI for investing that reads across every account you connect, taxable, IRA, and a spouse's accounts if you link them, in a single view. When it spots a position sitting at a loss, it can check the entire 61-day window across all of those accounts before it suggests anything, which is the check no single broker can run for you.
From there, Tengu finds the loss, proposes a compliant replacement that keeps you in the same market exposure without being substantially identical, and confirms that nothing you own or have scheduled would trip the rule, including buys sitting inside an IRA. Then it routes the trade to your broker, and only after you approve it. Tengu is non-custodial and consent-first. It never moves money on its own, every action waits for your explicit approval, and a kill switch is always in reach.
Two honest limits. Tengu does not execute at every broker. Where a broker does not support routed orders, it hands you a ready-to-place instruction instead of pretending to trade there. And it does not replace your accountant. It surfaces the harvest and the wash-sale risk clearly, cross-account, and you and your tax professional make the final call.
Key takeaways
- The wash-sale rule (IRC Section 1091) disallows a loss if you buy a substantially identical security within 30 days before or after the sale, a 61-day window in total.
- A disallowed loss in a taxable account is deferred, not lost: it adds to the replacement's cost basis and the holding period carries over.
- The rule spans all your accounts, including your IRAs and a spouse's, so no single broker can see the whole picture.
- A wash sale caused by a purchase inside an IRA is permanent, with no basis step-up to ever recover the loss.
- To harvest cleanly, wait 31 days or buy a similar but not substantially identical replacement, and check every account first.
- Tengu reads across every connected account, proposes a compliant replacement, and routes on your approval. This is education, not tax advice.
Frequently asked questions
How long do I have to wait to rebuy the same security?
At least 31 days after the sale, so that no purchase lands inside the window that runs 30 days before through 30 days after. Rebuying on day 31 or later avoids the wash sale on that repurchase.
If a wash sale happens, do I lose the tax benefit entirely?
In a taxable account, no. The disallowed loss is added to the basis of your replacement shares and comes back when you sell them in a clean transaction. The exception is a wash sale triggered by an IRA purchase, where the loss is permanently forfeited.
Does selling at a gain ever trigger a wash sale?
No. The wash-sale rule applies only to losses. If you sell at a gain, you owe tax on that gain and the rule is not in play.
Does the wash-sale rule apply to crypto?
As of 2026, the IRS generally treats most cryptocurrencies as property rather than securities, so Section 1091 has not applied to crypto the way it applies to stocks and funds. This is an active area with proposals to extend the rule, so confirm current treatment with a tax professional before relying on it.
Can my broker's 1099 miss a wash sale?
Yes. Brokers report wash sales within their own accounts, but they cannot see identical purchases in your other accounts, your IRA, or your spouse's accounts. Those still count, and reconciling them is your responsibility.