Wash Sale Rule Calculator
Did you trigger a wash sale? Enter your trades to see the disallowed loss, adjusted cost basis, and how the 61-day window works.
Original Purchase
Sale at Loss
Repurchase (Potential Wash Sale Trigger)
Wash Sale Rule: The Complete Guide
Everything you need to know about wash sales, the 30-day window, cost basis adjustments, and how to avoid accidentally losing your tax deduction.
The wash sale rule is an IRS regulation (Section 1091 of the Internal Revenue Code) that prevents taxpayers from claiming a tax deduction on a security sold at a loss if they purchase a "substantially identical" security within 30 days before or after the sale. The rule exists to stop investors from selling a stock purely to harvest a tax loss and then immediately buying it back — effectively maintaining their position while getting a tax break.
How the rule works in practice:
- You sell a stock at a loss. Normally, you could deduct this loss against capital gains (or up to $3,000 of ordinary income per year).
- You buy the same (or substantially identical) stock within 30 days before or after the sale. This creates a 61-day "danger zone" (30 days before + sale day + 30 days after).
- The loss is "disallowed." You cannot deduct it on your tax return for that year.
- The disallowed loss is added to the cost basis of the replacement shares. This means the loss is deferred, not permanently eliminated. When you eventually sell the replacement shares, your higher cost basis reduces the gain (or increases the loss) on that future sale.
Why the IRS created this rule: Without the wash sale rule, investors could repeatedly sell and immediately repurchase shares to generate unlimited tax losses while never actually exiting their position. The rule ensures that tax-loss harvesting requires genuine economic change — you need to actually be out of the position for at least 31 days.
The wash sale rule looks at a 61-day window centered on the sale date. Most people think of it as "30 days after," but the rule also applies to purchases made 30 days before the sale. This is where many active traders get caught.
The 61-day window breakdown:
- Day -30 to Day -1: If you bought replacement shares during this period and then sell the original shares at a loss, the purchase before the sale triggers the wash sale.
- Day 0: The day you sell at a loss.
- Day +1 to Day +30: If you repurchase within this period, the loss is disallowed.
Example of a before-sale trigger: On January 5, you buy 100 shares of XYZ at $40. On January 20 (15 days later), you sell your original 100 shares of XYZ at $35 for a $500 loss. Even though the repurchase happened before the sale, it was within 30 days, so the wash sale rule applies and the $500 loss is disallowed.
The safe zone: To guarantee you avoid a wash sale, wait at least 31 calendar days after the sale before repurchasing. If you sold on January 15, the earliest safe repurchase date is February 15. Some investors wait 32 days to add a margin of safety and avoid timezone edge cases with settlement dates.
Calendar days, not business days: The 30-day window counts calendar days (including weekends and holidays), not trading days. This catches investors who mistakenly count only trading days and repurchase too early.
When a wash sale is triggered, the disallowed loss is added to the cost basis of the replacement shares. This is the critical nuance that most investors miss: the loss isn't gone forever — it's deferred and baked into your new position.
The basis adjustment formula:
Adjusted Cost Basis = Repurchase Price + |Disallowed Loss Per Share|
Step-by-step example:
- You bought 100 shares of ABC at $50 per share ($5,000 total)
- You sold them at $35 per share ($3,500 proceeds) — a $1,500 loss ($15/share)
- Within 30 days, you repurchased 100 shares at $37 per share
- The $1,500 loss is disallowed (wash sale triggered)
- Your new cost basis = $37 + $15 = $52 per share ($5,200 total)
Why this matters for future sales: If you later sell those replacement shares at $55, your gain is $55 - $52 = $3/share ($300 total), not $55 - $37 = $18/share ($1,800 total). The disallowed loss effectively reduced your future gain by $1,500 — exactly the amount of the original disallowed loss.
Partial wash sales: If you sold 100 shares but only repurchased 60, only 60 shares worth of the loss is disallowed. The remaining 40 shares worth of loss ($15 × 40 = $600) is fully deductible.
Holding period carries over too: Your holding period for the replacement shares includes the time you held the original shares. This can be beneficial — it may mean your replacement shares already qualify for long-term capital gains rates when you sell them.
The wash sale rule applies when you repurchase "substantially identical" securities within the 61-day window. The IRS has never provided a precise definition, which creates a gray area that investors need to navigate carefully.
What is clearly substantially identical (wash sale applies):
- Same stock — Selling and rebuying the same company's common stock is the most obvious trigger.
- Options on the same stock — Selling shares at a loss and buying call options (or selling put options) on the same stock can trigger a wash sale.
- Convertible securities — Bonds or preferred stock that convert into the same common stock are considered substantially identical.
What is generally NOT substantially identical (wash sale probably doesn't apply):
- Different companies in the same industry — Selling Coca-Cola and buying Pepsi is not a wash sale. They are different securities even though they are in the same sector.
- Different index funds tracking different indexes — Selling an S&P 500 index fund and buying a Total Stock Market fund is generally considered safe, though aggressive tax authorities could challenge this.
- Stocks vs. bonds of the same company — Non-convertible bonds are different securities from common stock.
The gray area (proceed with caution):
- ETFs tracking the same index from different providers — Selling a Vanguard S&P 500 ETF (VOO) and buying an iShares S&P 500 ETF (IVV) is debatable. They track the same index and hold nearly identical positions, but they are technically different securities issued by different companies. Many tax professionals consider this risky.
- Mutual fund vs. ETF versions of the same fund — Some fund families offer both. These are very likely substantially identical.
When in doubt, the safest approach is to buy a meaningfully different security in the same sector or use a different index entirely. Consult a tax professional for gray-area situations.
Yes — and this is one of the most misunderstood aspects of the wash sale rule. Wash sales apply across ALL of your accounts, including IRAs, Roth IRAs, and your spouse's accounts. Many investors get caught because they think the rule only applies within a single brokerage account.
Cross-account scenarios that trigger wash sales:
- Taxable account to IRA: You sell stock at a loss in your taxable brokerage account, then buy the same stock within 30 days in your IRA or Roth IRA. This is a wash sale. Worse, because you cannot add the disallowed loss to the cost basis in an IRA (IRAs don't track cost basis the same way), the loss may be permanently disallowed.
- Between brokerages: You sell at a loss in your Fidelity account and buy within 30 days in your Schwab account. Same security, same person — wash sale.
- Spouse's account: If you file jointly, your spouse buying the same stock within 30 days of your loss sale can trigger a wash sale. The IRS looks at the household, not just the individual.
- Automatic reinvestment: If you have DRIP (dividend reinvestment) enabled and the stock pays a dividend within 30 days of your loss sale, the reinvested dividend shares can trigger a wash sale on the number of shares purchased.
The IRA wash sale trap is especially dangerous: In a normal taxable account, the disallowed loss gets added to the cost basis of the replacement shares — you recover it later. But with an IRA purchase, some tax professionals argue the loss is permanently lost because there's no mechanism to adjust the IRA's cost basis for individual lots. This is the worst-case scenario for wash sales and should be avoided at all costs.
How to protect yourself: Keep a calendar or spreadsheet that tracks sales at a loss across all accounts. If you sell at a loss, set a reminder for 31 days later before repurchasing. Turn off DRIP for stocks you plan to sell at a loss.
Avoiding wash sales requires discipline and planning, especially if you trade frequently or use tax-loss harvesting as a strategy. Here are practical steps to stay compliant.
Strategy 1: Wait 31+ days before repurchasing
The simplest approach. Sell the position, wait at least 31 calendar days, then repurchase if you still want the position. The risk is that the stock moves up significantly during the waiting period and you miss the recovery.
Strategy 2: Buy a similar (but not substantially identical) security
- Sell a single stock and buy a sector ETF (e.g., sell Apple, buy a Technology Select Sector ETF)
- Sell one index fund and buy a different index (e.g., sell an S&P 500 fund, buy a Total Stock Market fund)
- Sell stock in one company and buy a competitor (e.g., sell Microsoft, buy Google)
Strategy 3: Harvest losses at year-end
If you sell in late December, you only need to avoid repurchasing through late January. This concentrates your attention into a short window rather than tracking 61-day windows throughout the year.
Strategy 4: Turn off automatic reinvestment (DRIP)
Before selling at a loss, disable dividend reinvestment for that security. A DRIP purchase of even a few shares within 30 days can create a partial wash sale on a much larger loss sale.
Strategy 5: Coordinate across all accounts and with your spouse
If you and your spouse both trade, keep a shared log of loss sales. One spouse buying what the other just sold at a loss triggers the wash sale rule on joint returns.
Key tracking tips:
- Use a spreadsheet or calendar to log every loss sale with the "safe to repurchase" date (31 days later)
- Review all account activity (including IRAs) before repurchasing
- Set calendar reminders for the end of each 30-day window
Tax-loss harvesting is the strategy of intentionally selling investments at a loss to offset capital gains and reduce your tax bill. The wash sale rule is the primary constraint on this strategy — it prevents you from harvesting losses while maintaining identical exposure.
How tax-loss harvesting works without wash sales:
- You own Stock A at a $5,000 unrealized loss
- You sell Stock A to realize the $5,000 loss
- The $5,000 loss offsets $5,000 in capital gains from other investments (or up to $3,000 of ordinary income if you have no gains)
- After 31+ days, you can buy Stock A back if you still want the position
How wash sales interact with tax-loss harvesting:
- If you buy Stock A back within 30 days (or bought it within 30 days before selling), the entire harvesting exercise is negated. The loss is disallowed and your tax benefit disappears for this year.
- The workaround: Instead of buying Stock A back, buy Stock B — a similar but not substantially identical investment. This maintains your market exposure while avoiding the wash sale rule. After 31 days, you can swap back to Stock A if desired.
Robo-advisors and automated tax-loss harvesting:
Services like Wealthfront and Betterment automate tax-loss harvesting by selling losing positions and immediately replacing them with similar (but not identical) ETFs. They use pairs of correlated securities specifically designed to maintain exposure while complying with the wash sale rule. However, if you have the same securities in another account (like an IRA), the robo-advisor may not know about it, and you could accidentally trigger a wash sale.
Annual tax-loss harvesting limits: There is no limit on how much loss you can harvest to offset capital gains. However, if your losses exceed your gains, you can only deduct up to $3,000 of excess losses against ordinary income per year ($1,500 if married filing separately). Remaining losses carry forward to future years.
The disallowed loss does not disappear forever — it is deferred, not eliminated. This is the silver lining of the wash sale rule and the most important thing to understand when you accidentally trigger one.
How you get the loss back:
- The disallowed loss is added to the cost basis of your replacement shares. This means your replacement shares have a higher cost basis than what you actually paid.
- When you sell the replacement shares, the higher cost basis reduces your taxable gain (or increases your deductible loss) by exactly the amount of the originally disallowed loss.
- Net effect: The same total loss is recognized — just in a different tax year than you planned.
Example of loss recovery:
- Original loss: $1,500 (disallowed due to wash sale)
- Replacement shares purchased at $37/share, adjusted basis = $52/share
- You sell replacement shares 6 months later at $55/share
- Gain = $55 - $52 = $3/share (instead of $55 - $37 = $18/share)
- You pay tax on $300 gain instead of $1,800 gain — saving you $1,500 in taxable income, which is exactly the originally disallowed loss
The exception: IRA purchases
If you triggered the wash sale by buying in an IRA or Roth IRA, the situation is worse. Because IRAs do not track individual lot cost basis for tax purposes, many tax professionals consider the disallowed loss to be permanently lost in this scenario. There is no mechanism to "add back" the disallowed loss to IRA shares. This is a strong reason to never repurchase a recently-sold-at-a-loss security inside an IRA.
Chain wash sales: Be careful not to trigger another wash sale when selling the replacement shares. If you sell the replacement shares at a loss and buy the same stock again within 30 days, you create a chain of wash sales, perpetually deferring the loss. Some day-traders end up with enormous phantom cost bases on their shares because of repeated wash sales throughout the year.
Ready to build a professional valuation model?