The wash sale rule explained: what every investor needs to know

TrackMyShares Team

The wash sale rule trips up more investors than almost any other tax rule. You sell a stock at a loss, thinking you just saved yourself some taxes, and then you buy it back because you still like the company. The IRS says no. That loss is disallowed.

It sounds simple, but the details matter, and most people get at least one of them wrong.

What is the wash sale rule

The wash sale rule (IRC Section 1091) stops you from claiming a tax loss if you buy back the same or a "substantially identical" security too quickly. The IRS created it to prevent investors from selling purely for the tax benefit and immediately restoring their position.

The loss is not gone forever, though. It gets added to the cost basis of the replacement shares and deferred until you eventually sell those shares without triggering another wash sale.

The 61-day window

This is where most people get surprised. The wash sale window is not just 30 days after the sale. It is 61 days total:

  • 30 days before the sale
  • The sale day itself
  • 30 days after the sale

If you bought the same stock within 30 days before selling at a loss, that earlier purchase triggers the wash sale too.

Say you sell 100 shares of XYZ at a loss on March 15, 2026. The window runs from February 13 through April 14. Any purchase of XYZ (or a substantially identical security) during that range triggers the rule. To claim the loss, you need to have made zero purchases of XYZ during the entire 61 days.

What triggers a wash sale

The IRS applies the rule when you acquire a "substantially identical" security within the window. The obvious triggers:

  • Same stock. Sell AAPL at a loss, buy AAPL back. Wash sale.
  • Options on the same stock. Buying a call option or selling a put on the same underlying stock counts.
  • Different share classes of the same company. Selling Alphabet Class A (GOOGL) and buying Class C (GOOG) within the window? Same company, wash sale.
  • Contracts or rights to acquire the stock. Warrants and similar instruments count.

What generally does NOT trigger the rule:

  • Different companies in the same sector. Selling Microsoft and buying Google is fine, even though both are tech.
  • Different index funds tracking different indexes. Selling an S&P 500 ETF and buying a total stock market ETF is the classic tax-loss harvesting swap. It is a grey area if two funds track the same index. For the full breakdown, see our guide on substantially identical securities.
  • Bonds from different issuers.

Worked example

On June 1, 2025, you buy 100 shares of AAPL at $150/share ($15,000 cost basis). By November 10, the price has dropped to $120. You sell all 100 shares for $12,000, creating a $3,000 loss.

On November 25 (15 days later), AAPL ticks up to $125 and you buy 100 shares again for $12,500.

Result: Wash sale. The $3,000 loss is disallowed for tax year 2025.

But it is not gone. The $3,000 gets added to the cost basis of your replacement shares:

  • New cost basis: $12,500 + $3,000 = $15,500 ($155/share instead of $125/share)
  • If you later sell at $170/share ($17,000), your gain is $1,500 instead of $4,500. The $3,000 difference is your original disallowed loss finally being recognized.

Your replacement shares also inherit the holding period of the original shares, which can help them qualify for long-term capital gains rates sooner.

Common mistakes

Buying in an IRA or 401(k). This is the most expensive mistake. If you sell at a loss in a taxable account and buy the same stock in a retirement account within 30 days, the loss is disallowed, and since retirement accounts do not use cost basis the same way, the loss is effectively permanent. We have a full guide on wash sales and retirement accounts.

DRIPs. Automatic dividend reinvestment can silently trigger a wash sale. You carefully time a sale to harvest a loss, and three days later a DRIP buys a handful of shares of the same stock. We added wash sale detection partly because a user got stung by a DRIP purchase they did not even remember setting up.

Spouse accounts. The rule applies across accounts you and your spouse control. A purchase in their account can disallow your loss.

For details on partial wash sales and multiple-purchase scenarios, see our posts on how to report wash sales.

Strategies to avoid wash sales

  • Wait 31+ days before repurchasing. Simple, but you risk the stock moving against you.
  • Buy a similar but not identical security. Sell your S&P 500 ETF, buy a total stock market ETF. Maintain exposure, keep the loss.
  • Double up, then sell. Buy additional shares first, wait 31 days, then sell the original lot at a loss. Requires extra capital and doubles your exposure temporarily.
  • Turn off DRIP before harvesting a loss. Turn it back on after the 30-day window closes.
  • Coordinate with your spouse, especially around year-end.

How TrackMyShares detects wash sales

When you generate a tax report, TrackMyShares scans every loss sale and checks whether any purchase of the same security occurred within the 61-day window. Potential wash sales are flagged with the sale date, repurchase date, and disallowed loss amount.

The tax-loss harvesting tool also factors in wash sales when identifying harvesting opportunities, warning you if a potential harvest would be disallowed because of a recent purchase.

For a broader overview of using losses to reduce your tax bill, see our guide on capital gains tax on stocks.

Sign up for TrackMyShares to track your transactions, detect wash sales automatically, and make smarter tax decisions with your portfolio.

This is general information, not personal tax or financial advice.