The Wash Sale Rule: What U.S. Investors Need to Know

If you sell a stock at a loss and buy it back within 30 days, the IRS disallows that loss under the wash sale rule. The loss isn’t erased — it’s deferred by being added to the cost basis of your replacement shares. Two immediate actions: wait for more than the 61-day window before repurchasing, or replace the sold position with a security that isn’t substantially identical.
The controlling authorities are 26 U.S.C. §1091, Treasury Regulation §1.1091-1, IRS Publication 550, and Form 8949 with Schedule D for reporting. Know these four references and you know where every wash sale question ultimately gets resolved.
Immediate implications at a glance:
- Tax deduction deferred, not erased. The disallowed loss rolls into your replacement shares’ basis, reducing the gain (or increasing the loss) when you eventually sell those shares in a clean transaction.
- Basis adjustment. Your replacement shares carry a higher cost basis equal to their purchase price plus the disallowed loss.
- Holding period carryover. The holding period of the sold shares tacks onto the replacement shares, which can affect whether a future gain qualifies as long-term.
- IRA exception risk. If replacement shares are bought inside an IRA, the loss disallowed by the wash sale rule cannot be deferred, resulting in permanent loss of the deduction.
Key Takeaways
The wash sale rule disallows a loss when substantially identical securities are repurchased within the 61-day period, deferring the loss into the replacement shares’ adjusted basis — except when the replacement occurs inside an IRA or 401(k), where the loss can be permanently lost.
| Point | Details |
|---|---|
| The 61-day window | The rule covers 30 days before the sale, the sale date, and 30 days after — any repurchase inside this window disallows the loss. |
| Basis adjustment, not erasure | The disallowed loss adds to the replacement shares’ cost basis, deferring the tax benefit until those shares are sold in a clean transaction. |
| IRA and 401(k) risk | Replacement purchases inside tax-advantaged accounts can permanently eliminate the deferred loss — it cannot be added to IRA or 401(k) basis. |
| Reporting forms to watch | Brokers report wash sale amounts in Box 1g of Form 1099-B; you enter code W adjustments on Form 8949, with totals flowing to Schedule D. |
| Quantgenie for tax-aware planning | Quantgenie’s no-code backtesting platform can flag 61-day exposures and model tax-aware rebalancing before you execute trades. |
Table of Contents
- How the wash sale rule actually works
- What “substantially identical” means in practice
- Special cases that catch investors off guard
- How to avoid triggering a wash sale
- Reporting wash sales on your tax return
- Step-by-step numeric examples
- How algorithmic tools can help you avoid inadvertent wash sales
- Wash sale rules and 401(k)s, HSAs, and other tax-advantaged accounts
- How the wash sale rule applies to bonds, crypto, and other securities
- A perspective on what actually matters for retail investors
- Quantgenie can help you build tax-aware trading strategies
- Sources
How the wash sale rule actually works
The statute at 26 U.S.C. §1091 is direct: a loss deduction is disallowed when the taxpayer acquires substantially identical stock or securities within the 61-day period encompassing 30 days before and 30 days after the sale. That creates a 61-day window — 30 days before the sale date, the sale date itself, and 30 days after. Any purchase of substantially identical shares inside that window triggers the rule.
Treasury Regulation §1.1091-1 fills in the mechanics. When replacement shares are fewer than the shares sold, the regulation uses an order-of-acquisition matching rule: the earliest-acquired replacement shares are matched first against the sold shares. Only the matched portion of the loss is disallowed; any remaining loss on unmatched shares is deductible.
Basis adjustment formula: New basis of replacement shares = their original purchase price + the disallowed loss amount. This is the deferral mechanism — the tax benefit isn’t gone, it’s locked inside the replacement position until you sell it in a non-wash transaction.
Holding period tacking works the same way. The replacement shares inherit the holding period of the shares you sold. Sell shares you held for 200 days, buy replacements, and those replacements start life with a 200-day holding period already attached. That matters for the long-term capital gains rate threshold.
| Timeline | What happens |
|---|---|
| Day 0 (sale date) | Loss realized; 61-day window opens |
| Days 1–30 before sale | Purchases of substantially identical shares trigger the rule |
| Days 1–30 after sale | Purchases of substantially identical shares trigger the rule |
| Day 31+ after sale | Safe to repurchase without triggering the wash sale rule |

Example row: You sell 100 shares of XYZ on March 1 at a $500 loss. You buy 100 shares of XYZ on March 20. The $500 loss is disallowed. Your replacement shares’ basis increases by $500, and their holding period includes the period you held the original shares.
What “substantially identical” means in practice
“Substantially identical” is not exhaustively defined by the IRS, which creates real ambiguity. The conservative rule of thumb: same ticker, same fund share class, or a direct derivative on the same underlying security. Beyond that, you’re in judgment territory.
Securities that are clearly substantially identical:
- The exact same stock (selling 100 shares of AAPL and buying 100 shares of AAPL within 30 days)
- The same mutual fund share class (selling Class A shares and buying Class A shares of the same fund)
- Call options, put options, or convertible instruments on the same underlying stock — the statute at 26 U.S.C. §1091 explicitly includes contracts and options to acquire or sell stock
- Bonds from the same issuer with nearly identical terms (maturity, coupon, seniority)
Grey areas investors commonly encounter:
- Two ETFs tracking the same index (e.g., two S&P 500 ETFs from different fund families) — the IRS has not issued a bright-line ruling, but practitioners treat this as high-risk for “substantially identical” scrutiny
- Different share classes of the same fund (Class A vs. Class C) — likely identical; confirm with a tax professional
- Sector ETFs with overlapping but not identical holdings — generally lower risk, but the more similar the composition, the more exposure you carry
Crypto and digital assets sit in a particularly uncertain zone. Current IRS guidance does not explicitly apply the wash sale rule to cryptocurrency, since crypto is generally treated as property rather than “stock or securities” under §1091. That said, Congress has proposed legislation to extend the rule to digital assets, and practitioners advise treating crypto wash sales as a live compliance risk rather than a settled exemption. Don’t assume the current gap is permanent.
A note on ETFs: Switching from one S&P 500 ETF to a broad total-market ETF with a different index is generally considered safer than swapping between two funds tracking the exact same index. The difference in underlying index matters — but it doesn’t guarantee safety. Document your reasoning.
Special cases that catch investors off guard
IRA and tax-advantaged account purchases
This is the costliest trap. When you sell shares at a loss in a taxable account and then buy substantially identical shares inside an IRA within the 61-day period, the wash sale rule triggers — but the disallowed loss cannot be added to the IRA’s basis. IRAs don’t carry cost basis the same way taxable accounts do. The result: the loss is permanently gone, not deferred. You never get to use it.
H&R Block’s guidance flags this as one of the most common and expensive wash sale mistakes retail investors make. The fix is simple but requires discipline: either wait 31 days before buying back in any account, or replace the position with a non-substantially-identical security.
Cross-account and spouse purchases
The wash sale rule applies across all accounts you control, not just within a single brokerage. Sell at a loss in your Fidelity account and buy the same stock in your Schwab account within 30 days — that’s a wash sale. The same logic extends to purchases made by your spouse or by a corporation you control. The IRS looks at the economic substance of the transaction, not the account label.
Short sales and options
Treasury Regulation §1.1091-1 covers short sales and options explicitly. Entering a short sale on a stock you already hold at a loss, or buying a call option on a stock you just sold at a loss, can both trigger the rule. Cash-settled contracts don’t automatically escape coverage either — the regulation’s reach extends to contracts and options to acquire the underlying security.
The day trader exemption myth
Some active traders believe that trading frequently enough qualifies them for a dealer exemption from §1091. It doesn’t. IRS guidance makes clear that statutory dealer status is narrowly defined, and nearly all retail day traders — even those trading hundreds of times per year — do not qualify. The pattern day trader rule governs margin and account requirements, but it confers no wash sale exemption. If you’re trading actively and harvesting losses, §1091 applies to every transaction.
Pro Tip: Your broker’s 1099-B only reports wash sales within that single brokerage. Cross-broker wash sales — and purchases inside IRAs at other institutions — are your responsibility to track. Keep a consolidated trade log or use a tax-aware tool to reconcile activity across all accounts before filing.
How to avoid triggering a wash sale
These tactics work in practice, but each carries a tradeoff worth understanding before you act.
-
Wait 31 or more days before repurchasing. The cleanest solution. Sell the losing position, sit out the 30-day window, then buy back in. The tradeoff: 31 days of market exposure you don’t have. If the stock rallies during that window, you’ve paid a real opportunity cost to harvest a paper loss.
-
Replace with a non-substantially-identical security. Sell a losing S&P 500 ETF and immediately buy a total-market ETF or a different-index fund that gives similar but not identical exposure. You stay invested, preserve roughly the same market exposure, and realize the loss. The tradeoff: tracking error and transaction costs. If the replacement security moves differently than what you sold, your portfolio drifts.
-
Use tax-lot selection to choose long-held lots. If you hold multiple lots of the same stock purchased at different times, selecting the highest-cost lot for sale minimizes the loss amount subject to wash sale risk — and may generate a long-term loss, which is more tax-efficient. Most brokers let you specify lots at the time of sale.
-
Increase holdings slowly rather than replacing in full. If you want to add to a position you just sold at a loss, buying a smaller number of shares in a different security first, then waiting 31 days to buy back the original, can limit how much of the loss gets disallowed. This requires careful timing and tracking.
-
Disable dividend reinvestment (DRIP) during harvesting windows. Automated dividend reinvestment can silently trigger a wash sale. If a dividend reinvests into shares of a fund you just sold at a loss — or are about to sell — the reinvestment counts as a replacement purchase. Pause DRIP for positions you’re actively harvesting, and schedule trades to avoid reinvestment dates.
-
Watch automated rebalancing. Robo-advisors and target-date funds rebalance automatically. If your taxable account holds a fund that gets rebalanced into a substantially identical position within 30 days of a loss sale, you have a wash sale you didn’t intentionally create. Review your automated account settings before executing any tax-loss harvest.
Reporting wash sales on your tax return
The reporting chain runs from your broker to you: broker issues Form 1099-B, you transfer the information to Form 8949, and Form 8949 totals flow to Schedule D.
What to look for on Form 1099-B: Brokers are required by IRS Form 1099-B instructions to report wash sale adjustments in Box 1g. That box shows the dollar amount of the disallowed loss. The adjusted cost basis — original basis plus the disallowed loss — appears in Box 1e.
Completing Form 8949: Each wash sale transaction gets its own row. In the “Adjustment” column, enter code W and the amount from Box 1g as a positive number (it reduces your deductible loss). The adjusted basis from Box 1e goes in the cost basis column. IRS Publication 550 walks through this step by step.
Stepwise reporting process:
- Gather all trade confirmations and 1099-B forms from every brokerage account, including IRAs.
- Identify every transaction where Box 1g shows a wash sale adjustment.
- Verify the broker’s reported adjustment against your own records — brokers only track wash sales within their own platform.
- For cross-broker wash sales your broker didn’t catch, calculate the disallowed loss yourself and enter the adjustment manually on Form 8949 with code W.
- Carry the net totals from Form 8949 to the appropriate short-term or long-term section of Schedule D.
Pro Tip: If you traded across multiple brokerages and harvested losses near year-end, prepare an internal reconciliation worksheet before you file. Keep trade records for at least three years — the IRS statute of limitations for most returns. For complex situations involving IRAs or large cross-broker activity, a CPA or enrolled agent is worth the cost.
Step-by-step numeric examples
Example A: Simple equal-share replacement within 30 days
Per Treasury Regulation §1.1091-2, which provides step-by-step basis adjustment mechanics:
- You buy 100 shares of XYZ at $50/share on January 5. Cost basis: $5,000.
- You sell all 100 shares on February 10 at $40/share. Proceeds: $4,000. Realized loss: $1,000.
- You buy 100 shares of XYZ on February 25 — 15 days later, inside the 30-day window.
- Wash sale triggered. The $1,000 loss is disallowed.
- Adjusted basis of replacement shares: $4,000 (purchase price) + $1,000 (disallowed loss) = $5,000.
- Holding period carryover: The replacement shares inherit the January 5 start date.
- Tax outcome: When you eventually sell the replacement shares at $50, your gain is $0 (not $1,000). The deferred loss has been realized.
Example B: Partial replacement (fewer shares repurchased)
- You sell 100 shares of ABC at a $2,000 loss on March 1.
- You buy only 60 replacement shares of ABC on March 15.
- Under the order-of-acquisition matching rules in Treas. Reg. §1.1091-1, 60% of the loss ($1,200) is disallowed; the remaining $800 is deductible.
- The 60 replacement shares carry an adjusted basis equal to their purchase price plus $1,200.
Example C: Replacement inside an IRA
- You sell 100 shares of DEF in your taxable brokerage at a $3,000 loss on November 20.
- Your IRA automatically rebalances and purchases 100 shares of DEF on December 5 — 15 days later.
- Wash sale triggered. The $3,000 loss is disallowed.
- Critical difference: The disallowed loss cannot be added to the IRA’s basis. It is permanently lost.
- Tax outcome: You never recover that $3,000 deduction. The IRA shares’ basis is simply their purchase price — no adjustment.
| Scenario | Disallowed loss | Adjusted basis of replacement | Loss recovered? |
|---|---|---|---|
| A: Equal replacement, taxable | $1,000 | $5,000 | Yes, when replacement sold |
| B: Partial replacement, taxable | $1,200 (of $2,000) | Purchase price + $1,200 | Partially, on matched shares |
| C: IRA replacement | $3,000 | Purchase price only | No — permanently lost |
How algorithmic tools can help you avoid inadvertent wash sales
Tax-aware trading tools address a real operational problem: most investors don’t realize they’ve triggered a wash sale until their 1099-B arrives in February. By then, the window has closed and the loss is already disallowed.
Concrete use cases for algorithmic trade planners:
- Pre-trade wash sale flagging. A platform that tracks your open positions and trade history can flag a pending purchase as a potential wash sale before you execute — giving you the chance to wait or substitute a non-identical security.
- 61-day exposure monitoring. Automated tracking of the 61-day period across all connected accounts removes the manual calendar-watching that most investors skip.
- Substantially identical instrument identification. Backtesting platforms that maintain security metadata can flag when a proposed replacement security tracks the same index or holds substantially identical underlying assets.
- DRIP and rebalancing controls. Platforms with direct broker integrations can alert you when an automated dividend reinvestment or rebalancing event is about to purchase shares inside an active wash sale window.
- Consolidated trade history. When you trade across multiple brokers, a single consolidated ledger makes cross-broker wash sale detection possible — something no individual broker’s 1099-B will do for you.
For data quality in backtesting, the choice of market data source matters. A comparison of algorithmic trading data sources illustrates how data quality affects the reliability of any pre-trade or tax-aware simulation.
Limitations to state plainly: No software tool replaces a tax professional for complex situations. Tool-generated wash sale flags are based on the data you provide and the platform’s rule logic — they can miss cross-account activity you haven’t connected, and they cannot account for IRS interpretations of “substantially identical” that haven’t been codified. Always reconcile tool output against your broker’s 1099-B entries and consult a CPA or enrolled agent when the amounts are material.
Wash sale rules and 401(k)s, HSAs, and other tax-advantaged accounts
The IRS’s position on IRAs is well-established: purchases inside an IRA can permanently eliminate a disallowed loss because the loss cannot be added to IRA basis. The same logic extends to other tax-advantaged accounts, though the mechanics differ.
401(k) plans present a subtler problem. Most 401(k) participants don’t control the exact timing of purchases inside their plan — contributions are invested on a payroll schedule, and target-date funds rebalance automatically. If your 401(k) holds a fund that is substantially identical to a position you just sold at a loss in a taxable account, and the 401(k) purchases shares of that fund within the 61-day period, a wash sale can occur. Like the IRA scenario, the disallowed loss cannot be added to the 401(k)'s basis, making the loss permanent.
Health Savings Accounts (HSAs) carry the same risk. An HSA is a tax-advantaged account, and purchases inside it follow the same logic as IRA purchases for wash sale purposes. If you invest your HSA in a fund substantially identical to a position you’re harvesting losses on in a taxable account, the wash sale rule can apply — and the loss is gone.
The practical takeaway: before executing any tax-loss harvest, review what your 401(k), IRA, and HSA are currently holding and whether any automatic purchases are scheduled within the 61-day period. This is harder than it sounds when target-date funds and automatic contribution schedules are involved, which is exactly why many tax professionals recommend a simple 31-day wait rather than trying to navigate the timing precisely.
How the wash sale rule applies to bonds, crypto, and other securities
Bonds
Bonds are “securities” under §1091, so the wash sale rule applies. The “substantially identical” analysis for bonds focuses on the issuer, maturity date, coupon rate, and seniority. Two Treasury bonds with the same maturity and coupon are clearly substantially identical. A 10-year Treasury and a 7-year Treasury from the same issuance series are less clear. Municipal bonds from different issuers are generally not substantially identical, which makes muni bond tax-loss harvesting more straightforward than equity harvesting.
Cryptocurrency
This is where the current law creates a genuine planning opportunity — and a compliance risk. Cryptocurrency is treated as property under IRS Notice 2014-21, not as “stock or securities.” Under the current statutory text of §1091, the wash sale rule does not apply to crypto. You can sell Bitcoin at a loss on Monday and buy it back on Tuesday without triggering a wash sale.
That said, Congress has repeatedly proposed legislation to close this gap. The Build Back Better Act included a provision extending wash sale rules to digital assets; it didn’t pass, but similar proposals keep reappearing. Treating the crypto wash sale exemption as permanent is a planning risk. If legislation passes mid-year, it could apply to transactions after the effective date, catching investors who assumed the exemption would hold.
Other securities
Warrants, rights, and convertible preferred stock can all fall within §1091’s scope when they are contracts or options to acquire substantially identical stock. Foreign stocks traded on U.S. exchanges are covered. American Depositary Receipts (ADRs) representing shares of a foreign company are generally treated as substantially identical to the underlying foreign shares for wash sale purposes.
A perspective on what actually matters for retail investors
Most retail investors spend too much time worrying about the edge cases — whether two ETFs are “substantially identical,” whether a small DRIP purchase triggered a partial wash sale — and not enough time on the two things that actually move the needle: robust recordkeeping and simple, consistent avoidance rules.
The IRS’s definition of “substantially identical” will never be perfectly clear. Practitioners disagree on specific ETF pairs. What is clear is that the 31-day wait rule eliminates the problem entirely for any position you’re willing to exit for a month. For most retail investors harvesting losses at year-end, that’s the only rule they need. Pick a non-identical replacement if you can’t stomach the market risk of being out for 31 days — but document your reasoning for why the replacement isn’t substantially identical.
The IRA trap deserves more attention than it gets. Losing a loss permanently because a 401(k) or IRA rebalanced at the wrong moment is a real, recurring mistake. The fix costs nothing: check your tax-advantaged accounts before you harvest, and pause automatic investments in substantially identical positions during the 61-day period.
Repeated wash sales across multiple years do something insidious to your tax records: they create a chain of basis adjustments that compounds with every transaction. After three or four years of active harvesting without clean reconciliation, your cost basis records can be genuinely unreliable. That’s when a CPA earns their fee — not just for the current year’s return, but to reconstruct a basis history that your broker’s records may not fully capture.
The long-term after-tax return difference between an investor who manages wash sales carefully and one who doesn’t isn’t just about the current year’s deduction. It’s about whether the deferred losses actually get realized in a tax-efficient way, or whether they get buried in a chain of basis adjustments that never produce a clean deduction.

Quantgenie can help you build tax-aware trading strategies
Tax-loss harvesting is only as good as your ability to track what you own, when you bought it, and what the 61-day period looks like across every account you hold. That’s an operational problem as much as a tax problem.

Quantgenie’s no-code algorithm platform lets you build, backtest, and simulate trading strategies with institutional-grade market data — including pre-trade checks that can flag potential wash sale exposures before you execute. Describe your strategy in plain English, and Quantgenie translates it into a deterministic algorithm you can test against validated historical data. You can model tax-aware rebalancing scenarios, identify substantially identical instruments in your replacement candidates, and consolidate trade history for cleaner year-end reconciliation. Quantgenie is a planning and backtesting tool, not a tax advisor — for complex situations, always confirm with a qualified CPA or enrolled agent. Ready to build smarter, tax-aware strategies? Start building on Quantgenie today.
Sources
The primary sources below are where the rules actually live. When in doubt, go to the statute and the IRS publication first.
- 26 USC § 1091: Loss from wash sales of stock or securities
- 26 CFR § 1.1091-1 - Losses from wash sales of stock or securities.
- IRS Publication 550, Investment Income and Expenses (Including Capital Gains and Losses)
- Investor
- What Is the Wash Sale Rule and Impact on Taxes | H&R Block
For complex situations — multiple brokerages, active harvesting across tax-advantaged accounts, or large capital loss carryforwards — consult a CPA or enrolled agent. The rules are clear in principle; the application to specific multi-account scenarios is where professional judgment earns its keep.
This article is general information, not a substitute for advice from a qualified financial advisor. Consult a qualified financial professional about your own circumstances before acting on anything here.
