The Wash Sale Rule Explained

The wash sale rule disallows a tax deduction on an investment loss if you acquire the same or substantially identical security within 30 days before or 30 days after the sale date. That creates a window spanning 61 calendar days in total, so it is neither strictly a 30-day nor a 60-day rule in practice. In a taxable account, the disallowed loss is added to the cost basis of your replacement shares, so the deduction waits until you sell those shares.

At ModernWallet, we find that what readers get wrong most often is assuming the rule only looks forward in time. Buying replacement shares two weeks before you sell a losing lot disallows the loss just as buying them two weeks after does. Trading bots and AI agents make this easy to miss, because they can buy the stock back in a separate account without asking you.

Tools for this journey

The Mechanics of the 30-Day Window Before and After

Under Internal Revenue Code Section 1091, the statutory window begins 30 days before the date of the sale at a loss and ends 30 days after that date. Counting the day of the sale itself alongside the 30 days preceding it and the 30 days following it yields an arithmetic total of 61 days. If you execute a sale on July 15 at a capital loss, any acquisition of substantially identical assets between June 15 and August 14 can trigger the restriction.

The rule covers more transactions than direct purchases of common stock. IRS Publication 550 establishes that entering into a contract or option to acquire substantially identical stock or securities counts as an acquisition for wash sale purposes. This includes purchasing call options or warrants on the stock you just sold at a loss. Selling bonus-award shares at a loss while receiving another award of substantially identical stock within 30 days also disallows the deduction.

The rule also reaches beyond transactions registered exclusively in your personal name. If you sell stock at a loss and your spouse buys substantially identical shares within the window, the IRS treats the transaction as a wash sale. The same restriction applies if a corporation you control purchases the replacement shares. The rule also applies under Section 1091(e) to losses on closing a short sale if you sell substantially identical stock or enter another short sale within 30 days before or after closing the position.

Basis Adjustments and Holding-Period Additions

When a wash sale occurs, the disallowed loss is not permanently eliminated from your taxable holdings. Publication 550 instructs you to add the disallowed dollar amount directly to the cost basis of the newly acquired replacement shares. This upward basis adjustment postpones your tax deduction until you ultimately dispose of those replacement shares in a future, unwashed transaction.

Publication 550's Example 1 shows the math. Suppose you purchase 100 shares of stock X for $1,000. You later sell those 100 shares for $750, realizing a $250 loss. Within 30 days of that sale, you purchase 100 replacement shares of stock X for $800. Because the purchase falls inside the wash sale window, your $250 loss is not deductible on your current tax return. Instead, you add the $250 disallowed loss to the $800 purchase price, giving your new 100 shares an adjusted cost basis of $1,050.

Along with the basis increase, the holding period of your original stock attaches to your replacement stock. If you held the initial shares for ten months before selling at a loss, your newly acquired shares automatically inherit that ten-month period on day one. This provision helps determine whether a subsequent sale qualifies for long-term treatment as outlined in our ordinary income vs. capital gains tax comparison.

The Facts and Circumstances of Substantially Identical Securities

The tax code does not provide a mechanical, mathematical formula for what makes two financial instruments substantially identical. Publication 550 states that you must evaluate all facts and circumstances in each situation. Ordinarily, stocks or securities issued by one corporation are not considered substantially identical to those issued by an entirely separate corporation.

Exceptions exist when corporate structures merge or overlap. For example, securities issued by predecessor and successor corporations involved in a corporate reorganization can be treated as substantially identical under IRS scrutiny. Bonds or preferred stock are not ordinarily substantially identical to the same company's common stock. Convertible bonds or convertible preferred stock can be, depending on their relative values, price changes and other circumstances.

For mutual funds and exchange-traded funds, Publication 550 does not publish a bright-line test. Publication 550 does not say whether two funds that track the same index, such as two S&P 500 funds from different managers, are substantially identical. Because no safe-harbor list exists for fund pairs, a replacement fund that tracks a different market segment carries less doubt; our portfolio rebalancing guide covers choosing one.

Partial Share Matching and the IRA Trap

When the quantity of shares bought within the window does not match the quantity sold, Publication 550 requires a lot-by-lot matching sequence. You must match the replacement shares bought with an equal number of shares sold, starting with the earliest purchases made during the window. A wash sale on a partial position disallows only the loss attributable to the matched replacement lots.

Publication 550 demonstrates this with an exact dated scenario. An investor buys 100 shares of company M on September 20, 2024, for $5,000. On December 13, 2024, the investor buys 50 shares for $2,750, and on December 20, 2024, buys 25 shares for $1,125. On January 3, 2025, the investor sells the original 100 shares for $4,000, creating an overall $1,000 loss. Because 75 shares were acquired within the preceding 30 days, the loss on 75 shares ($750) is disallowed, while the loss on the remaining 25 shares ($250) is immediately deductible. The basis of the December 13 lot increases to $3,250 ($2,750 plus $500), and the basis of the December 20 lot increases to $1,375 ($1,125 plus $250).

The rule is harsher if you buy the replacement shares in an IRA or a Roth IRA. Revenue Ruling 2008-5, published in Internal Revenue Bulletin 2008-3, covers this case. If you sell stock at a loss and have your IRA or Roth IRA buy substantially identical stock within 30 days before or after the sale, the loss is disallowed under Section 1091. The individual's basis in the IRA is not increased. Because that basis does not go up, you never recover the disallowed loss.

Cross-Account Trading and Autonomous Bot Execution

Brokerage firms are only required to calculate and report wash sales for covered securities sharing the same CUSIP number within a single brokerage account. Under the official Form 1099-B instructions, a broker is permitted, but not required, to aggregate transactions across different accounts. If you sell a stock at a loss at one brokerage and buy it back two weeks later at another, your Form 1099-B may show no disallowed loss. Publication 550 says you still cannot deduct it.

The same gap applies when software buys for you. As explained in our breakdown of Robinhood agentic trading, an AI agent can trade in its own account. If that agent buys a stock you sold at a loss in your main account within 30 days, you have a wash sale that your Form 1099-B may not flag.

An agent trading in the Robinhood 24 Hour Market can make that purchase overnight, before you check your account. Robo-advisors that harvest tax losses raise the same question, and our best robo-advisors roundup covers how each handles tax-loss harvesting. You remain personally responsible for identifying and adjusting every matching trade on your return regardless of automated origin.

Tax Reporting on Form 1099-B and Form 8949

When a wash sale happens within a single taxable brokerage account involving identical CUSIPs, your financial institution will detail the adjustment directly on Form 1099-B. Box 1g will show the exact dollar amount of the wash sale loss disallowed.

To report these transactions accurately to the IRS, you transfer the figures to Form 8949, Sales and Other Dispositions of Capital Assets, using either Part I for short-term trades or Part II for long-term holdings. Per the Form 8949 instructions, you list the details of the transaction, enter the capital "W" in column (f) to designate a wash sale, and write the disallowed loss as a positive number in column (g). Entering the positive number in column (g) reduces the net capital loss claimed on that trade line.

If the number in box 1g of Form 1099-B is incorrect because the repurchase happened in another account, or if a wash sale occurred that the broker did not track, you must input the correct calculation in column (g). If your actual wash sale disallowance is lower than what the broker stated, the IRS instructions require you to attach an explanatory statement to your tax return explaining why the broker figure was adjusted. Our tax tips guide covers the records to keep before you file.

Digital Asset Treatment and Pending Legislation

The text of Section 1091 specifies that wash sale limitations apply to sales or trades of "stock or securities." Under current federal tax guidance, the IRS classifies digital assets as property, citing Notice 2014-21. Because general property transactions follow general tax principles rather than the specific provisions of Section 1091, conventional cryptocurrencies have historically not been restricted by statutory wash sale disallowance rules.

However, tokenized securities represent a distinct category subject to standard reporting. Under the official Form 1099-DA instructions, brokers must report disallowed wash sale losses in box 1i for transactions involving tokenized securities treated as stock or securities under Section 1091. Same-account and same-CUSIP reporting principles apply to these digital securities exactly as they do to traditional equity assets.

Pending federal legislation could extend the rule to most digital assets. On September 16, 2026, the House Ways and Means Committee voted 38 to 5 to approve H.R. 10357, known as the Digital Asset Tax Certainty Act, according to an Unchained report on H.R. 10357. If enacted, the bill would extend wash sale rules to traded digital assets other than qualified dollar stablecoins, retroactive to sales occurring after September 14, 2026. A Forvis Mazars analysis notes that broader House and Senate action remains uncertain, leaving the bill as unpassed legislation rather than settled law.

Mark-to-Market Elections for Qualifying Active Traders

Day traders are subject to the wash sale rule unless they make a mark-to-market election. IRS Topic 429 says traders without that election remain subject to both the capital loss limits and the wash sale rules. If you trade the same stock in and out many times, disallowed losses keep rolling into your newest shares, so your return can show taxable gains in a year your account balance fell.

To bypass these restrictions, a qualifying trader must make a formal mark-to-market election under Section 475(f) of the tax code. IRS Topic 429 confirms that traders who make a valid Section 475(f) election are not subject to wash sale rules or regular capital loss deduction limits.

Trader tax status is a separate question from the pattern day trader rule, which is a margin rule at your broker. Publication 550 also notes that dealers in stock or securities are exempt from wash sale disallowance for losses incurred in the ordinary course of business. Talk to a tax professional before you make a Section 475(f) election.

Practical Execution Tactics to Avoid Unintended Disallowance

The simplest way to stay clear is to wait until the 31st day after the sale to buy back; for a July 15 sale, that is August 15. Also make no purchase of the same stock in the 30 days before the sale. If you want to stay invested in the meantime, you can buy a different holding, such as a broad fund. Publication 550 gives no test for funds, so the facts-and-circumstances standard decides whether a replacement is substantially identical.

Automatic purchases count as purchases. If a recurring buy purchases more shares of the stock within 30 days of your loss sale, the matching rule disallows the loss on that many shares, so pause recurring buys of that stock around the sale.

If you run a trading bot or an AI agent, tell it not to buy any ticker you plan to sell at a loss, from 30 days before the sale until the 31st day after it. Once that window passes, check your trade log before you let it trade the ticker again.

Frequently asked questions

Is the wash sale rule 30 or 60 days?

The statutory rule covers 30 days before and 30 days after your sale date, spanning an arithmetic total of 61 calendar days when including the sale day itself. Because replacement purchases made in the 30 days leading up to the sale trigger disallowance just like purchases made afterward, the rule operates over this combined two-sided window.

Can I sell a stock and buy it back within 30 days?

Yes, you can legally buy it back at any time, but doing so within 30 days disallows your ability to claim the capital loss on your tax return. Instead, your disallowed loss is added to the cost basis of the newly purchased shares, deferring the tax deduction until those new shares are sold in an unwashed transaction.

Can I claim a loss after a wash sale?

You cannot claim the loss in the tax year the wash sale occurs, but the loss is usually deferred rather than lost forever. Because the disallowed amount gets added to the replacement stock's cost basis, you will realize the tax benefit when you eventually sell the replacement position, provided that final sale is not another wash sale.

How do day traders avoid wash sales?

Day traders avoid wash sales by either waiting 31 calendar days before re-entering a losing position, trading completely different instruments, or qualifying for Trader Tax Status and making a Section 475(f) mark-to-market election. A valid mark-to-market election exempts qualifying traders from wash sale rules entirely under IRS Topic 429.

Does the wash sale rule apply to crypto?

Current tax law treats digital assets as property rather than stock or securities, so standard cryptocurrency transactions are not subject to Section 1091 wash sale rules today. However, tokenized securities are covered, and H.R. 10357, a bill approved by a House committee, would apply the rule to most digital assets sold after September 14, 2026, if enacted.

Does the wash sale rule apply across different brokerage accounts?

Yes. The wash sale rule applies across all your accounts, including IRAs, and to purchases by your spouse or a corporation you control. While individual brokers only report wash sales that occur within the same account for the exact same CUSIP, you are legally responsible for tracking and reporting cross-account wash sales on Form 8949.

Sources

We prioritize primary sources for rules, formulas, rates, limits, and definitions. See our calculator methodology and editorial policy.