Last updated:
What the Wash Sale Rule Is
The wash sale rule is an IRS regulation, codified in Internal Revenue Code Section 1091, that prevents investors from claiming a capital loss deduction when they sell a security at a loss and repurchase the same or a substantially identical security within a 61-day window, 30 calendar days before the sale, the day of sale itself, and 30 calendar days after. The purpose of the wash sale rule is to block a tax shelter strategy in which an investor sells a losing position purely to realize a tax deduction while immediately buying back the same position to maintain their economic exposure to the security. Congress created the rule because, without it, investors could manufacture paper losses at will while remaining fully invested, gaining a tax advantage unavailable to investors who don't trade. The wash sale rule calculator above applies the exact same 30-day test the IRS uses to determine whether your specific repurchase triggers a disallowed loss.
Understanding the wash sale rule is essential for any investor who practices tax-loss harvesting, the strategy of selling losing positions to offset capital gains or deduct up to $3,000 of net capital losses against ordinary income per year. According to the IRS Publication 550 on Investment Income and Expenses, the wash sale rule applies not only to stocks but also to bonds, mutual funds, exchange-traded funds, and options on substantially identical securities. Violations are surprisingly common because the rule applies across all accounts you control, including IRAs, your spouse's accounts, and accounts held at different brokerages, not just the account where the sale occurred. Explore our tax-loss harvesting calculator to model the full benefit of loss harvesting once you've confirmed the wash sale rule won't erase your deduction.
The 30-Day Window Explained
The 30-day wash sale window is frequently misunderstood as a window that runs only after the sale date. In fact, the IRS wash sale rule is symmetric: it applies to purchases made 30 days before the sale just as strictly as to purchases made 30 days after. This means a tax-loss harvesting strategy can be inadvertently violated before the sale even happens. For example, if you purchased 100 shares of a stock on November 1 and then decided to harvest a loss by selling your original 100 shares on November 20, just 19 days after the new purchase, the wash sale rule is triggered even though you sold after buying. The wash sale rule calculator displays a visual timeline showing the full 61-day prohibited window so you can verify your repurchase date at a glance.
The 30-day count is in calendar days, not trading days, which is another source of confusion. Weekends and market holidays count toward the 30 days. A sale on November 15 creates a window from October 16 through December 15, any substantially identical purchase within that range, at any brokerage, in any account you control, triggers the wash sale rule. Many brokerage platforms now flag wash sales automatically in their tax reporting, but they can only track purchases within the same account; cross-account violations must be tracked manually. Using the 30-day wash sale rule calculator before executing repurchases gives you a precise boundary for safe reinvestment. You can also visit our taxes tools category for additional calculators that complement your year-end tax planning.
How Adjusted Cost Basis Works After a Wash Sale
One of the most important and misunderstood aspects of the wash sale rule is that a disallowed loss is not permanently lost. It is deferred. When the wash sale rule disallows a loss, the IRS requires you to add that disallowed loss to the cost basis of the replacement shares you purchased. This adjusted cost basis means that when you eventually sell the replacement shares, your taxable gain will be smaller (or your deductible loss will be larger) by the amount of the disallowed loss. For example, if you sell 100 shares at a $1,500 loss, violate the wash sale rule by repurchasing 100 shares at $47 per share ($4,700 total), and your disallowed loss is $1,500, your adjusted cost basis in the new shares is $4,700 + $1,500 = $6,200. The wash sale rule calculator computes this adjusted basis automatically so you know exactly what cost basis to report.
The holding period of the replacement shares also carries over from the original shares. If the original shares were held for 11 months before the wash sale, and you sell the replacement shares one month after repurchasing, the IRS treats the total holding period as 12 months, qualifying for long-term capital gains treatment at the lower preferential rate. This carryover of the holding period can be advantageous when the original shares were close to the 12-month long-term threshold. Use our capital gains tax calculator to estimate the tax impact of a future sale with your adjusted cost basis factored in.
What Counts as Substantially Identical
The term "substantially identical" is central to the wash sale rule calculator's determination, and the IRS has deliberately left it undefined in statute to give the agency flexibility in applying it to new investment products. What is clear from IRS guidance and court cases is that selling shares of a company and repurchasing shares of the exact same company is always substantially identical. Selling a mutual fund and buying a different fund from the same fund family that tracks the same index has been treated as substantially identical in IRS rulings. Selling a call option on a stock and buying the underlying stock can also trigger the rule, as can selling the stock and buying deep-in-the-money call options that are nearly equivalent to owning the shares.
The most popular tax-loss harvesting work-around is to sell a position and immediately reinvest in a similar but not substantially identical security. For example, selling the SPDR S&P 500 ETF (SPY) and buying the iShares Core S&P 500 ETF (IVV) is widely considered to be acceptable because the two funds are issued by different companies, even though they track the same index. Similarly, selling a Vanguard Total Bond Market ETF and buying an iShares Core U.S. Aggregate Bond ETF is generally treated as not substantially identical. However, the IRS has not formally blessed any specific fund pairs, and the determination involves facts and circumstances. Consult a qualified tax professional before relying on a specific fund swap if the amounts are large. According to FINRA's investor guidance on tax-loss harvesting, investors should document why replacement securities are not substantially identical at the time of the trade.
How to Avoid Wash Sales During Tax-Loss Harvesting
The most straightforward way to avoid triggering the wash sale rule is to wait a full 31 calendar days after selling a losing position before repurchasing the same or substantially identical security. This strategy is clean and simple but comes with the risk that the market rises during the waiting period and you miss out on the recovery. For investors who cannot afford to be out of the market for a month, the fund-swap approach, reinvesting immediately in a similar but not substantially identical security, is the standard alternative. After the 31-day window closes, you can then switch back to the original security if you prefer it.
A less obvious but equally important step is to audit all of your accounts, taxable brokerage accounts, traditional IRAs, Roth IRAs, and your spouse's accounts, for any purchases of the same security made within the 30-day window before or after your sale. Automatic dividend reinvestment plans (DRIPs) are a particularly common source of inadvertent wash sales: if a stock pays a dividend and automatically reinvests it in additional shares within 30 days of a loss sale, the wash sale rule is triggered on the number of shares purchased via the DRIP. Suspending DRIP enrollment before harvesting a loss and re-enrolling after the window closes is a simple precaution. For investors with large, multi-lot positions, the cost basis calculator can help you identify which lots to sell to maximize your deductible loss while minimizing the wash sale exposure.