The wash sale rule explained: what every investor needs to know
The wash sale rule is one of the most commonly misunderstood tax rules for investors. It can catch you off guard, turning what you thought was a tax-saving move into a disallowed loss. If you sell a stock at a loss and buy it back too quickly, the IRS will not let you claim that loss on your taxes.
In this guide, we explain exactly how the wash sale rule works, what triggers it, what happens to your disallowed loss, and how to avoid common mistakes.
Disclaimer: This article is for informational purposes only and does not constitute financial or tax advice. Consult a qualified tax professional before making investment decisions based on tax considerations.
What is the wash sale rule
The wash sale rule is an IRS regulation under Section 1091 of the Internal Revenue Code. It prevents investors from claiming a tax deduction on a loss if they purchase the same or a "substantially identical" security within a specific window around the sale.
The purpose of the rule is to stop investors from selling a stock purely to realize a loss for tax purposes and then immediately buying it back to maintain their position. Without this rule, investors could harvest tax losses repeatedly without actually changing their portfolio.
When a wash sale is triggered, the loss is not permanently gone. Instead, it is added to the cost basis of the replacement shares. This means the loss is deferred until you eventually sell the replacement shares without triggering another wash sale.
The 61-day window
The wash sale window is wider than many investors realize. It is not simply 30 days after the sale. The full window spans 61 days:
- 30 days before the sale date
- The day of the sale itself
- 30 days after the sale date
This means that if you bought the same stock within 30 days before selling at a loss, that purchase can trigger a wash sale just as easily as buying it back after the sale.
Timeline example
Suppose you sell 100 shares of XYZ stock at a loss on March 15. The wash sale window is:
- Start of window: February 13 (30 days before March 15)
- Sale date: March 15
- End of window: April 14 (30 days after March 15)
Any purchase of XYZ stock (or a substantially identical security) between February 13 and April 14 triggers the wash sale rule. To safely claim the loss, you would need to ensure you did not purchase XYZ during this entire 61-day period.
What triggers a wash sale
The IRS applies the wash sale rule when you acquire a "substantially identical" security within the 61-day window. Here is what counts:
Same stock
Buying back the exact same stock you sold at a loss is the most straightforward trigger. If you sell 100 shares of Apple at a loss and repurchase any number of Apple shares within the window, it is a wash sale.
Options on the same stock
Purchasing a call option or selling a put option on the same underlying stock can trigger a wash sale. The IRS views these as acquiring a position in the same security, even though options and shares are technically different instruments.
Different share classes of the same company
If a company has multiple share classes (for example, Class A and Class C shares), selling one class at a loss and purchasing the other within the window may trigger a wash sale. The IRS considers these substantially identical because they represent ownership in the same company.
Contracts or rights to acquire the stock
Entering into a contract to buy the same stock, or acquiring rights to purchase it (such as through warrants), can also trigger the rule.
What does NOT trigger a wash sale
The IRS does not provide a complete list of what is not substantially identical, but the following are generally considered safe:
Different companies in the same sector
Selling shares of one tech company and purchasing shares of a different tech company is typically fine. Even though both stocks are in the same sector, they are not substantially identical securities. For example, selling Microsoft at a loss and buying Google shares within 30 days would not trigger a wash sale.
Different index funds tracking different indexes
This is a common strategy for maintaining market exposure while harvesting a loss. For example, selling an S&P 500 ETF at a loss and purchasing a total stock market ETF. However, this is a grey area. If two funds track very similar indexes and have nearly identical holdings, the IRS could potentially consider them substantially identical. The more different the underlying indexes, the safer the approach.
Bonds from different issuers
Selling one corporate bond at a loss and purchasing a bond from a different issuer is generally not a wash sale, even if the bonds have similar characteristics.
Worked example: a basic wash sale
Let's walk through a straightforward example.
Step 1: The original purchase
On June 1, 2025, you buy 100 shares of AAPL at $150 per share. Your total cost basis is $15,000.
Step 2: The sale at a loss
On November 10, 2025, AAPL has dropped. You sell all 100 shares at $120 per share, receiving $12,000. Your capital loss is $3,000 ($12,000 - $15,000).
Step 3: The repurchase
On November 25, 2025, just 15 days later, AAPL recovers slightly. You decide to buy 100 shares again at $125 per share, paying $12,500.
Result: Wash sale triggered
Because you repurchased the same stock within 30 days of the sale, the $3,000 loss is disallowed. You cannot deduct it on your taxes for the 2025 tax year.
What happens when the wash sale is triggered
A disallowed wash sale loss does not simply vanish. The IRS requires you to add the disallowed loss to the cost basis of the replacement shares. This adjustment preserves the economic benefit of the loss for the future.
Adjusted cost basis example
Continuing the example above:
- Disallowed loss: $3,000
- Cost of replacement shares: $12,500 (100 shares at $125)
- Adjusted cost basis: $12,500 + $3,000 = $15,500
Your 100 replacement shares now have a cost basis of $15,500 ($155 per share) instead of $12,500 ($125 per share).
How this affects future sales
When you eventually sell the replacement shares, the higher cost basis means a smaller gain (or larger loss). Suppose you later sell those 100 shares at $170 per share ($17,000 total):
- Without wash sale adjustment: $17,000 - $12,500 = $4,500 gain
- With wash sale adjustment: $17,000 - $15,500 = $1,500 gain
The $3,000 difference in gain corresponds exactly to the original disallowed loss. So the loss is not permanently lost. It is simply deferred until you sell the replacement shares.
Holding period adjustment
In addition to the cost basis adjustment, the holding period of the replacement shares includes the holding period of the original shares. This can be beneficial because it may help the replacement shares qualify for the lower long-term capital gains rate sooner.
Common mistakes investors make
Buying in an IRA or other retirement account
One of the most painful wash sale scenarios occurs when you sell a stock at a loss in a taxable brokerage account and then buy the same stock in your IRA, 401(k), or other retirement account within the 30-day window. This triggers the wash sale rule, and the loss is disallowed.
The problem is that losses inside retirement accounts are generally never deductible. So the disallowed loss gets added to the cost basis of shares inside the IRA, where it provides no tax benefit. This effectively makes the loss permanent.
Dividend reinvestment plans (DRIPs)
If you have automatic dividend reinvestment turned on, a DRIP purchase of the same stock within the wash sale window can trigger the rule. Even though the purchase is automatic and may involve only a small number of shares, it counts.
This is particularly easy to overlook. You might carefully time a sale to harvest a loss, only to have a dividend reinvestment a few days later trigger a wash sale on some or all of the loss.
Spouse accounts
Under IRS rules, the wash sale rule applies across accounts controlled by you and your spouse. If you sell a stock at a loss in your brokerage account and your spouse buys the same stock in their account within 30 days, the wash sale rule applies.
Partial wash sales
You do not need to repurchase the same number of shares to trigger a wash sale. If you sell 200 shares at a loss but only repurchase 50 shares within the window, the rule applies to the proportional amount. In this case, 25% of the loss (corresponding to the 50 replacement shares) would be disallowed, and the remaining 75% of the loss could still be claimed.
Multiple purchases within the window
If you make several purchases of the same stock within the 61-day window, each purchase can trigger a separate wash sale. The matching of shares sold to shares purchased follows IRS guidelines, and the calculations can become complicated when multiple lots are involved.
Strategies to avoid wash sales
If you want to harvest a tax loss and stay within the rules, here are several approaches:
Wait 31 or more days before repurchasing
The simplest approach is to sell the stock, wait at least 31 calendar days, and then repurchase it. This ensures you are outside the wash sale window.
The risk is that the stock may move significantly during those 31 days. If it rises, you will pay more to repurchase. If it falls further, you will benefit from the lower price.
Buy a similar but not identical security
Instead of repurchasing the same stock, you can buy a different security that provides similar market exposure. For example:
- Sell an S&P 500 ETF and buy a total stock market ETF
- Sell shares of one energy company and buy shares of a different energy company
- Sell one tech stock and buy a sector ETF
This approach lets you maintain similar exposure while harvesting the loss. Just make sure the replacement security is not "substantially identical" to the one you sold.
Double up, then sell
Another strategy involves buying additional shares of the stock first (doubling your position), waiting 31 days, and then selling the original shares at a loss. Because the purchase of the new shares happened more than 30 days before the sale, no wash sale is triggered.
This strategy requires additional capital and doubles your exposure to the stock for the 31-day waiting period, which introduces extra risk.
Turn off dividend reinvestment
Before harvesting a loss, check whether you have automatic dividend reinvestment enabled for the stock. If so, turn it off before selling to avoid an accidental wash sale from a DRIP purchase.
Coordinate with your spouse
Make sure your spouse is aware of your tax-loss harvesting plans. A purchase in their account can trigger a wash sale on your loss. Communication is essential, especially around year-end when tax-loss harvesting is most common.
How TrackMyShares detects wash sales
TrackMyShares automatically scans your transaction history for potential wash sales. Here is how the feature works:
Automatic 61-day scanning
When you generate a tax report for a portfolio, TrackMyShares examines every sale that resulted in a loss. For each loss sale, it checks whether any purchase of the same security occurred within the 61-day window.
Clear flagging
When a potential wash sale is detected, the transaction is flagged in your tax report. The report shows:
- The sale date and loss amount
- The repurchase date that triggered the wash sale
- The disallowed loss amount
- The adjusted cost basis of the replacement shares
Works across your portfolio
TrackMyShares checks for wash sales across all holdings of the same security within a portfolio. If you have the same stock in multiple lots and sell one lot at a loss while purchasing another, the system will flag it.
Tax-loss harvesting integration
The tax-loss harvesting feature in TrackMyShares takes wash sales into account when identifying harvesting opportunities. If a potential harvest would trigger a wash sale (because of a recent purchase within the window), the tool warns you before you act.
Wash sales and tax-loss harvesting
The wash sale rule is the single biggest constraint on tax-loss harvesting strategies. Understanding the rule is essential before you attempt to harvest losses, because a poorly timed repurchase can negate the entire tax benefit.
Key points to keep in mind:
- Always check the 61-day window before and after any loss sale
- Remember that the rule applies across all your accounts (including IRAs and spouse accounts)
- Automatic dividend reinvestment can silently trigger wash sales
- The loss is deferred, not eliminated, but deferral can still cost you if you do not sell the replacement shares in a tax-advantaged way
For a broader overview of how to use losses to reduce your tax bill, see our guide on capital gains tax on stocks.
The wash sale rule adds complexity to tax planning, but it does not have to catch you off guard. With the right tools and awareness, you can harvest losses effectively while staying within the rules.
Sign up for TrackMyShares to track your transactions, detect wash sales automatically, and make smarter tax decisions with your portfolio.