Wash Sale Rule Explained: The 30-Day Window, Cost Basis, and IRA Traps

Selling an investment for less than you paid does not always give you a loss you can deduct this year. If you buy the same security, or one that is substantially identical, too close to the sale, the wash sale rule can push that deduction into the future. If the purchase happens inside an IRA, the loss may be gone for good.
The wash sale rule is easy to trip over because it looks backward as well as forward. A purchase made three weeks before a losing sale counts just as much as one made three weeks after it. A small dividend reinvestment can count too. This guide walks through the window, the basis math, the IRA problem and the records that make the rule easier to manage. Sources were reviewed on November 20, 2026.
Key Takeaways
- The window is 61 days: the wash sale rule looks at 30 calendar days before a loss sale, the sale date and 30 days after it.
- It only touches losses: selling at a gain and buying back the same shares does not trigger a wash sale.
- Most wash sales defer the loss: in a taxable account, the disallowed loss is added to the basis of the replacement shares.
- IRA purchases are different: the IRS says a loss is disallowed when your IRA buys the replacement, and your IRA basis does not go up.
- Spouses count: a purchase by your spouse or a corporation you control can create a wash sale.
- Partial buys create partial wash sales: the disallowed share of the loss follows the number of replacement shares.
What Is the Wash Sale Rule?
The wash sale rule stops an investor from claiming a tax loss while keeping essentially the same position. Congress wrote it into section 1091 of the tax code, and the IRS explains it in Publication 550. The core idea is simple: if your economic position barely changed, the tax code does not let you book the loss yet.
According to IRS Publication 550, a wash sale happens when you sell or trade stock or securities at a loss and, within 30 days before or after the sale, you do one of four things. You buy substantially identical stock or securities. You acquire them in a fully taxable trade. You acquire a contract or option to buy them. Or you acquire substantially identical stock for your traditional IRA or Roth IRA.
Who the Rule Covers
The rule reaches further than your own brokerage account. Publication 550 says that if you sell stock and your spouse or a corporation you control buys substantially identical stock, you also have a wash sale. That means a household with two people trading the same fund in separate accounts can create a wash sale without either person noticing it at the time of the trade.
Dealers in stock or securities are the main exception. The wash sale rule does not apply to a dealer's loss when the trade happened in the ordinary course of the dealer's business. For most individual investors, that exception is not relevant, so every losing sale in a taxable account deserves a quick check of purchases on both sides of the trade date.
What the Rule Does Not Cover
The rule only applies to losses. If you sell shares at a gain and buy them back the next day, there is no wash sale, and the gain is taxed as usual. Publication 550 also says the rule does not apply to losses on commodity futures contracts and foreign currencies, which follow separate tax rules described elsewhere in the same publication.
The rule also does not stop you from selling. It only changes when, and sometimes whether, you can deduct the loss. Many investors read the rule as a ban on trading, but it is a timing and basis rule. You can still rebalance, cut a position or harvest a loss, as long as you understand how the replacement purchase will be treated.
How the 30-Day Window Works
The 30-day window is measured in calendar days, not trading days. Weekends and market holidays count. The full span is 61 days when you include the sale date itself: 30 days before, the day of the sale and 30 days after. A purchase anywhere in that span can be matched against the loss.
The table below shows how common trade patterns line up with the window. Each row assumes the replacement is substantially identical to the shares sold at a loss, which is a separate question covered later in this guide.
| Trade Pattern | Likely Result Under the Rule |
|---|---|
| Buy identical shares 20 days before a loss sale | Wash sale can apply |
| Buy identical shares 15 days after a loss sale | Wash sale can apply |
| Buy identical shares 31 or more days after the sale | That purchase is outside the window |
| Sell at a gain and buy back the next day | No wash sale, because there is no loss |
| Your spouse buys identical shares 10 days after your loss sale | Wash sale can apply |
| Your IRA buys identical shares after your taxable loss sale | Loss disallowed with no basis increase |
The two halves of the window catch different mistakes, so each is worth a closer look.
The Look-Back Half
The 30 days before the sale catch many investors off guard. Suppose you add to a position in early December, the price falls and you sell your older, higher-cost shares at a loss later that month. The December purchase sits inside the look-back period. Part or all of the loss on the older shares can be disallowed even though you never bought anything after the sale.
This is why automatic investment plans deserve attention. A monthly purchase scheduled for the 15th of each month will almost always fall within 30 days of any sale you make. If you plan to sell a fund at a loss, check whether a recurring buy of the same fund landed in the prior 30 days or is scheduled for the next 30.
The Look-Forward Half
The 30 days after the sale are the better known half of the window. If you sell at a loss and buy the same shares back within that period, the wash sale rule can apply. Waiting until day 31 keeps that particular purchase outside the window, though it does not undo any purchase you made in the 30 days before the sale.
Waiting also has a market cost. While you hold cash, the price can rise, and you may buy back at a higher level than you sold. Some investors buy a different investment during the gap. That approach only works if the replacement is not substantially identical, and the IRS treats that question as one of facts and circumstances.
How a Wash Sale Changes Your Cost Basis
In a normal taxable account, a wash sale does not erase your loss. Publication 550 says you add the disallowed loss to the cost of the new stock or securities, and the result becomes your basis in the new position. The IRS describes this adjustment as one that postpones the loss deduction until you dispose of the new shares.
The holding period moves too. Publication 550 says your holding period for the new stock or securities includes the holding period of the shares you sold. This can change whether a later sale counts as short-term or long-term. The short-term vs long-term capital gains comparison explains why that one-year line can change the tax rate on a gain.
A Worked Basis Example
Here is a hypothetical trade. You buy 100 shares for $5,000. Later you sell all 100 for $4,000, a $1,000 loss. Ten days after the sale, you buy 100 substantially identical shares for $4,200. Because the purchase falls inside the window and the share counts match, the $1,000 loss is disallowed for now.
Your basis in the new shares becomes $5,200: the $4,200 purchase price plus the $1,000 disallowed loss. If you later sell the new shares for $5,500, your gain would be $300 rather than $1,300. The loss did not vanish. It moved into the replacement shares and reduced the later gain. These figures illustrate the mechanism and are not a real trade or a suggestion to trade.
The IRS Example in Publication 550
The IRS gives its own simpler version. You buy 100 shares of X stock for $1,000, sell them for $750 and, within 30 days, buy 100 shares of the same stock for $800. You cannot deduct the $250 loss. Instead, you add the $250 to the $800 cost, so your basis in the new shares is $1,050.
Both examples share the same logic. The disallowed loss rides along with the replacement shares. When you finally sell those shares in a transaction that is not itself a wash sale, the higher basis lowers your gain or increases your loss. You can model the gain side with the capital gains tax calculator once you know the adjusted basis.
What Happens When You Buy Back Fewer Shares?
A partial repurchase creates a partial wash sale. Publication 550 says that when the number of replacement shares is more or less than the number sold, you match the shares bought with an equal number of shares sold. You match them in the order you bought them, starting with the first shares bought in the window.
Here is a simple version. You sell 100 shares at a $1,000 loss, which works out to $10 per share. Within the window you buy 40 substantially identical shares. Assuming the loss per share is equal across the lot, $400 of the loss is disallowed and added to the basis of those 40 shares. The other $600 can be deducted, subject to the usual capital loss rules.
The IRS Matching Example
Publication 550 walks through a longer case. You buy 100 shares of M stock for $5,000. Weeks later you buy 50 more for $2,750, then 25 more for $1,125. You then sell the original 100 shares for $4,000, a $1,000 loss. Because 75 substantially identical shares were bought within 30 days before the sale, you cannot deduct the $750 loss on 75 shares.
You can still deduct the $250 loss on the other 25 shares. The $750 disallowed amount is split across the replacement lots. The 50 shares get two-thirds, or $500, for a new basis of $3,250. The 25 shares get the remaining $250, for a new basis of $1,375. The example shows why share counts and purchase order shape the outcome.
Why Dollar Totals Mislead
Looking only at dollars bought and sold can give the wrong answer. A $500 reinvested dividend might buy only a handful of shares, and only those shares are matched. On the other hand, a large purchase made before the sale can absorb the entire loss even if you never meant it as a replacement. The rule tracks shares and dates, not intent.
Publication 550 adds one more limit. A loss from a wash sale of one block of stock cannot be used to reduce gains on identical blocks sold the same day. If you sell several lots together, some at a gain and some at a loss, the disallowed loss on one lot does not net against the gains on the others.
Why an IRA Purchase Can Make the Loss Permanent
This is the most expensive version of the rule. Publication 550 lists an IRA or Roth IRA purchase as one of the four ways to trigger a wash sale. The IRS addressed the result in Revenue Ruling 2008-5, which covers an individual who sells stock at a loss and causes an IRA or Roth IRA to buy substantially identical stock within 30 days before or after the sale.
The ruling says the loss is disallowed under section 1091 and the individual's basis in the IRA or Roth IRA is not increased. In a taxable account, the disallowed loss would have moved into the replacement shares. Inside an IRA, there is no such adjustment, so the deferred deduction does not come back later in the usual way.
Why the Basis Rule Differs
The ruling explains the background. An individual has basis in a traditional IRA only to the extent that the account includes nondeductible contributions. Distributions are generally taxed unless they are allocable to that basis. Adding a disallowed loss to the price of shares inside the IRA would not create usable basis under those rules, which is why the ruling treats the loss as disallowed without the normal adjustment.
Publication 550 reflects the same point. In its basis instructions, the IRS says you add the disallowed loss to the cost of the new shares, except when the replacement was acquired for your IRA. That single exception turns a timing difference into a lasting one for many investors who coordinate trades across account types.
Common IRA Wash Sale Triggers
Several ordinary habits can cause this. Selling a fund at a loss in a taxable account in December and buying the same fund in an IRA during a year-end contribution is one. Another is having a target-date or index fund set to reinvest dividends in an IRA while selling the same fund at a loss in a brokerage account.
Each of these can feel like routine account management rather than a trade. The rule does not care about the label. If the IRA acquires substantially identical shares inside the 61-day span, the IRS treats it as a wash sale. Reviewing every account in the household before selling at a loss is the most direct way to spot a conflict.
What Counts as Substantially Identical?
There is no simple list. Publication 550 says you must consider all the facts and circumstances in your particular case. It adds that stocks or securities of one corporation are ordinarily not substantially identical to those of another corporation, though they may be in some cases, such as a reorganization where predecessor and successor stocks can qualify.
Bonds or preferred stock are ordinarily not substantially identical to the same company's common stock. Publication 550 notes an exception when bonds or preferred stock are convertible into the common stock and the relative values, price changes and other circumstances make them alike. Warrants also have their own treatment in the publication.
Funds and ETFs
Funds are the gray area most readers ask about. Publication 550 does not provide a list of fund pairs that are or are not substantially identical. Two funds that track the same index from different issuers raise a harder question than two funds that track different indexes. Websites that declare a pair safe or unsafe are offering an opinion, not IRS guidance.
A cautious approach is to treat the question as a judgment call with tax risk. Differences in the underlying index, holdings and structure all count as facts. Investors who rely on a replacement fund during the window should document why they believe it is different and consider asking a tax professional, especially when large losses are involved.
Options and Contracts
The rule also covers contracts and options. Publication 550 says acquiring a contract or option to buy substantially identical stock or securities within the window can create a wash sale. It also says the wash sale rules apply to losses from sales or trades of contracts and options to acquire or sell stock or securities.
Short sales have a separate rule. The wash sale rules apply to a loss on a short sale if you sell, or enter into another short sale of, substantially identical stock within 30 days before or after the date the short sale is complete. Options and short sales add complexity quickly, and the detailed examples in Publication 550 are worth reading before trading around a loss.
How Wash Sales Are Reported
Brokers report some wash sales for you, but not all of them. Publication 550 says Form 1099-B, box 1g, shows the amount of wash sale loss disallowed when the shares sold were covered securities and the replacement shares had the same CUSIP number and were bought in the same account. Trades across accounts or brokers may not appear on the form.
The IRS is direct on this point. Publication 550 says you cannot deduct a loss from a wash sale even if it is not reported on Form 1099-B. In other words, the broker form is a starting point. The taxpayer is responsible for catching wash sales involving a spouse, an IRA, another broker or a similar security with a different CUSIP.
Form 8949 Entries
Publication 550 explains the mechanics. You report a wash sale transaction in Part I or Part II of Form 8949, with the appropriate box checked, and complete all columns. You enter "W" in column (f) and the amount of the loss not allowed, as a positive number, in column (g). Those totals then flow to Schedule D.
Because column (g) holds a positive adjustment, the reported loss shrinks by the disallowed amount. Software usually handles this when the broker data is complete. Manual entries are often needed for cross-account wash sales, which is why keeping your own record of each lot and adjustment is useful before tax season arrives.
Records Worth Keeping
A practical wash sale log has a row for each lot. It shows the purchase date, the share count, the cost, the sale date, the proceeds and any basis adjustment from a prior wash sale. It also notes which account held the shares and whether a spouse or an IRA traded the same security nearby.
Keeping this log helps in two ways. It shows the true basis of replacement shares when you sell them years later. It also creates evidence of your reasoning when you treated two funds as different. Investors who hold several asset types can compare their trade-offs in the crypto vs stocks guide.
Tax Loss Harvesting Without Tripping the Rule
Tax loss harvesting means selling investments at a loss to offset gains or, within limits, ordinary income. The wash sale rule is the main constraint on the practice. Harvesting works best when the investor plans the full 61-day window, checks every account and decides in advance what, if anything, to hold during the gap.
A simple pre-sale checklist covers four points. First, list every purchase of the same or a similar security in the prior 30 days, across all household accounts. Second, pause automatic purchases and dividend reinvestment for that security. Third, decide whether to hold cash or a clearly different investment for the next 30 days. Fourth, record the trade details for your own files.
Planning the 30-Day Gap
The gap after a harvested sale is where most decisions happen. Holding cash removes wash sale risk but leaves the money out of the market for a month. Holding a different investment keeps money invested, but the replacement must not be substantially identical. Writing down the reason for your choice before trading makes the decision easier to defend later.
When Deferral Is Acceptable
Not every wash sale is a problem. In a taxable account, the loss usually moves into the replacement shares. If you plan to hold those shares for years, the deferral may cost little. The bigger risk is the IRA version, where the deduction can disappear, and the household version, where a spouse's trade goes unnoticed.
Each investor's situation differs, and this guide does not tell you whether to harvest, sell or buy any security. The goal is to understand the mechanics well enough to ask the right questions. For complex cases with options, multiple brokers or large losses, a qualified tax professional can review the facts before you file.
The Bottom Line
The wash sale rule turns on three questions: did you sell at a loss, did you or a related account acquire something substantially identical within 30 days on either side, and where did that purchase happen? In a taxable account, the answer usually means a deferred loss and a higher basis. In an IRA, it can mean a lost deduction.
A dated log of every lot across every household account is the most reliable defense. Brokers catch the simple cases, but the IRS holds the taxpayer responsible for the rest.
Frequently Asked Questions
Is the Wash Sale Window 30 or 60 Days?
It covers 30 calendar days before a loss sale and 30 days after, plus the sale date. That makes a 61-day span, measured in calendar days rather than trading days.
Does the Wash Sale Rule Apply to Gains?
No. The rule only limits loss deductions. Selling at a gain and buying the same shares back right away does not create a wash sale; the gain is taxed normally.
Can a Wash Sale Happen in an IRA?
Yes. If your IRA or Roth IRA buys substantially identical stock within the window, the loss is disallowed. Revenue Ruling 2008-5 says your IRA basis does not increase.
Does My Spouse's Purchase Count?
Yes. IRS Publication 550 says that if you sell stock at a loss and your spouse buys substantially identical stock within the window, you also have a wash sale.
Will My Broker Catch Every Wash Sale?
No. Form 1099-B shows wash sales only for covered securities with the same CUSIP bought in the same account. You still cannot deduct an unreported wash sale loss.
Resources
- IRS Publication 550, Investment Income and Expenses
- IRS Internal Revenue Bulletin 2008-3, Revenue Ruling 2008-5
- IRS Topic 409, Capital Gains and Losses
This article explains tax rules for general education. It is not tax, legal, investment or personalized financial advice.
