Can You Sell Stock at a Loss and Buy It Back? Wash Sale Rules

You can sell a stock at a loss and buy it back, but if you repurchase the same or a substantially identical security within 30 days before or after the sale, the IRS wash sale rule disallows the loss on your tax return. The loss is not erased forever. It gets added to the cost basis of the replacement shares, so you recover the tax benefit when you eventually sell those. The trap is in the details: dividend reinvestments, purchases in your IRA, and buys by your spouse can all disallow a loss you were counting on.

The 30-Days-Before, 30-Days-After Window

The wash sale rule in Internal Revenue Code Section 1091 blocks your loss deduction if you acquire a substantially identical security in the period beginning 30 days before your sale and ending 30 days after it. Counting the sale day itself, that is a 61-calendar-day span.1Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities Direction does not matter. Buying on March 1 and selling at a loss on March 20 triggers the rule just as much as selling first and buying back later.

Count calendar days, not trading days. Weekends and holidays do not pause the clock. The window also covers contracts and options to acquire the security, so entering a call option on the same stock during that period counts as a repurchase.2eCFR. 26 CFR 1.1091-1 – Losses From Wash Sales of Stock or Securities

What Counts as the Same Stock

The IRS decides whether two securities are “substantially identical” on all the facts and circumstances, not a bright-line test.3Internal Revenue Service. Publication 550 (2024), Investment Income and Expenses Buying back the exact same stock obviously counts. Stocks of two different corporations are ordinarily not treated as identical to each other, which is what makes some replacement strategies possible.

Preferred stock or bonds of the same company can be treated as substantially identical to that company’s common stock when the preferred is convertible into common without restriction and trades in line with the conversion ratio. Options and warrants on the same underlying stock also qualify.

Mutual Funds and ETFs

The IRS has never issued a definitive ruling on when two index funds cross the line. Selling one S&P 500 fund and immediately buying a different provider’s S&P 500 fund is risky, because both hold nearly the same basket in the same weights. Selling an S&P 500 fund and buying a total market or Russell 1000 fund involves a genuinely different index, and most tax practitioners consider that swap safe. Pick a replacement that tracks a meaningfully different index if you want to sit comfortably.

Where the Disallowed Loss Goes

A disallowed loss is deferred, not destroyed. Section 1091(d) adds the loss to the basis of the replacement shares.1Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities If you paid $5,000 for shares, sold them for $3,000 (a $2,000 loss), and immediately repurchased for $3,000, your new basis becomes $5,000. When you eventually sell those replacement shares, the built-in $2,000 comes back to you as a smaller gain or a larger loss.

Your holding period carries over too. Months you held the original shares get tacked onto the replacement shares, which matters because assets held longer than one year qualify for long-term capital gains rates.4Office of the Law Revision Counsel. 26 USC 1222 – Other Terms Relating to Capital Gains and Losses Hold the original for 11 months, trigger a wash sale, and your new shares start with 11 months already on the clock.

Buying Back Only Part of Your Position

The wash sale rule matches shares one for one. Sell 100 shares at a loss, buy back 75 within the window, and the loss is disallowed only on 75 shares. The remaining 25 shares’ worth of loss stays deductible. On a $1,000 total loss, that means $750 is disallowed (and shifted to the basis of the 75 new shares) and $250 remains available on your return. You do not have to avoid the stock entirely to salvage part of the deduction.

The Traps That Quietly Kill the Loss

The rule does not care which account holds the replacement purchase, and it does not care whether you clicked “buy” yourself.

Buying in Your IRA or Roth IRA

Sell stock at a loss in a taxable account, buy the same stock in your IRA or Roth IRA within 30 days, and the loss is disallowed under Revenue Ruling 2008-5.5IRS. Revenue Ruling 2008-5 Because you cannot adjust the basis of assets inside a retirement account, the loss is gone for good. Every other wash sale defers the loss; this one destroys it. It is the most expensive wash sale mistake an individual investor can make.

Purchases by Your Spouse

The IRS treats a purchase by your spouse as a wash sale on your loss. If your spouse buys the same stock within the 61-day window, even in a separate account at a different brokerage, the loss is disallowed.

Automatic Purchases You Forgot About

Automated buys are the classic self-inflicted wash sale. Common culprits:

  • Dividend reinvestment plans. If the stock you just sold pays a dividend inside the window, automatic reinvestment buys new shares and triggers the rule. Even a tiny reinvestment can disallow a large loss. Turn reinvestment off before harvesting.
  • RSU vesting. Restricted stock units that vest within 30 days of a loss sale on the same company’s stock count as an acquisition. Plan loss sales around known vesting dates.
  • ESPP purchases. Employee stock purchase plan buy dates are set by the plan, and a scheduled purchase inside the window triggers a wash sale on any recent loss sale of that stock.

Cross-Broker Reporting Gaps

Your broker only has to report wash sales that happen within the same account on the same CUSIP.6Internal Revenue Service. Instructions for Form 1099-B If you sell at Fidelity and buy at Schwab, neither 1099-B will flag it, and you are still responsible for reporting the wash sale. Relying on your 1099-B alone invites an audit adjustment.

How to Sell at a Loss and Stay Deductible

Capital losses first offset capital gains dollar for dollar, and excess losses reduce ordinary income by up to $3,000 per year ($1,500 if married filing separately), with unused amounts carrying forward indefinitely.7Office of the Law Revision Counsel. 26 USC 1211 – Limitation on Capital Losses Three ways to keep the deduction intact:

  • Wait 31 days. Sell, wait 31 full calendar days, then repurchase. The real cost is market exposure during the gap.
  • Buy a similar but not identical fund. Sell your S&P 500 ETF and immediately buy a total market or large-cap fund tracking a different index. You keep similar exposure without triggering the rule.
  • Repurchase only part of the position. You lose the deduction on the repurchased shares and keep it on the rest.

What you cannot do is sell in a taxable account and buy in your IRA. That permanently kills the loss instead of deferring it.

Year-End Timing

The 61-day window ignores the calendar year boundary. Sell on December 15 to book the loss this year, buy back on January 5, and the loss is disallowed because the repurchase is still within 30 days of the sale.1Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities The disallowed amount just shifts into the next tax year through the replacement shares’ basis.

For December tax-loss harvesting, either sell by around November 30 so the 31-day waiting period clears before year-end, or plan to stay out of the position until mid-January. Selling on December 31 and buying back on January 2 is one of the most common wash sale errors.

A Note on Cryptocurrency

Section 1091 applies to “stock or securities.”1Office of the Law Revision Counsel. 26 USC 1091 – Loss From Wash Sales of Stock or Securities The IRS classifies cryptocurrency as property rather than a security, so the wash sale rule does not currently apply to crypto. You can sell Bitcoin at a loss and buy it back the next day. A bipartisan discussion draft circulated in late 2025 proposed extending the rule to cryptocurrency, and legislation is widely expected in 2026, so confirm the current state of the law before you rely on this.

Reporting a Wash Sale on Your Return

Wash sales get reported on Form 8949, which flows into Schedule D. Enter code “W” in column (f) of Form 8949 and the disallowed loss as a positive number in column (g).8Internal Revenue Service. 2025 Instructions for Form 8949 – Sales and Other Dispositions of Capital Assets You need the sale date, the replacement purchase date, your original basis, the sale proceeds, and the disallowed amount.

Because your 1099-B may miss wash sales across accounts or brokerages, identify them yourself and report each one.6Internal Revenue Service. Instructions for Form 1099-B If the adjustments span multiple accounts, paying for professional tax preparation is worth it, because the basis carryover compounds year after year if you get it wrong.