The saving grace of making a poor stock or mutual fund investment in a taxable brokerage firm account is that you at least get a capital loss when you sell. The loss can then offset gains from your more successful investments, unless the dreaded wash-sale rules disallow your write-off. Here’s the scoop on this nasty little piece of the tax code.

The skinny on wash-sales

Your anticipated tax loss is disallowed if, within the period beginning 30 days before the date of the loss sale and ending 30 days after that date, you acquire “substantially identical” stocks or securities. For purposes of this article, let’s call them replacement securities.

According to the tax law, your loss transaction and the purchase of the replacement securities are a “wash,” so you shouldn’t be allowed any tax benefits. Please understand, however, that this righteous concept applies only to losses. If you sell for a gain and buy back identical stocks or securities within the above time frame, Uncle Sam is happy to collect his due with no qualms. (Among us tax professionals, this is known as a “heads I win; tails you lose” rule.)

Options are included in the definition of stocks and securities, so you can also have a wash-sale when you unload options at a loss.

But for the wash-sale rules to come into play, the stocks or securities must truly be substantially identical. Stocks or securities issued by one corporation are not considered substantially identical to stocks or securities of another.

What about replacing one S&P 500 index mutual fund with another? Unfortunately, the IRS begs the question by saying only that all circumstances must be considered in evaluating whether stocks or securities are substantially identical. What the heck does that mean? Nobody knows. In my opinion, no mutual fund is substantially identical to another. That said, you should be wary of selling, for example, one S&P 500 index fund for a loss and then buying into another S&P 500 index fund within 30 days.

Also, don’t think you can have your spouse buy identical replacement securities without running afoul of the wash-sale rules. Your tax loss is still disallowed. Ditto if your controlled corporation or IRA makes the buy, according to the IRS.

What happens to your loss?

The only good news about wash-sales is that your disallowed loss doesn’t just go up in smoke. Instead, it gets added to the basis of the replacement securities. When you sell them, your disallowed loss effectively reduces your gain or increases your loss on that transaction. Also, the holding period of the wash-sale securities is added to the holding period of the replacement securities, which increases your odds of qualifying for the favorable tax rate (15% for most folks under the current rules) on long-term capital gains.

Example 1: Say you purchased 100 shares of XYZ Co. on Dec. 1, 2018, for $2,000. On April 1, 2019, you sell the shares for $1,200, thus incurring an $800 short-term loss. But on April 10, 2019, you have a change of heart and buy back 100 shares for $1,300. Your $800 loss is disallowed, but it gets added to the basis of the replacement shares. So your basis becomes $2,100 ($1,300 plus the $800 disallowed loss). In addition, the holding period for the replacement shares includes the Dec. 2, 2018, through April 1, 2019, holding period of the shares for which the loss was disallowed. When you file your 2019 return, report the wash-sale on Part I of Form 8949, which feeds into Schedule D, since it was a short-term transaction (See the Schedule D instructions for full details on reporting wash-sales).

What happens if the number of replacement shares purchased during the forbidden 61-day period is less than or greater than the number of shares sold in the loss-sale transaction? Good question. The following two examples illustrate the answers.

Example 2: You bought 100 shares of XYZ Co. on Dec. 1, 2018, for $2,000. You then bought an additional 50 shares on March 1, 2019, for $1,200 and another 25 shares on March 10, 2019, for $650. On March 27, 2019, you sold all the December shares for $1,300, thus incurring a $700 loss. However, since you bought 75 replacement shares within 30 days of the loss sale, 75% of your loss ($525) is disallowed. You can deduct the other 25% ($175). Add two-thirds of the disallowed loss ($350) to the basis of the 50 shares bought on March 1. Add the remaining $175 of disallowed loss to the basis of the 25 shares bought on March 10. So the basis of the 50 shares becomes $1,550 ($1,200 plus the $350 disallowed loss) and the basis of the 25 shares becomes $825 ($650 plus the $175 disallowed loss). Also, you get to extend the holding period for both sets of shares by the Dec. 2, 2018, through March 27, 2019, holding period of the 75 shares for which the loss was disallowed.

Example 3: You bought 100 shares of XYZ Co. on Dec. 1, 2018, for $2,000. You then bought an additional 100 shares on March 1, 2019, for $2,400 and another 50 shares on March 10, 2019, for $1,300. On March 27, 2019, you sold all the December shares for $1,300, thus incurring a $700 loss. Since you bought 150 replacement shares within 30 days of the loss sale, your entire loss is disallowed. In this case, you add the entire disallowed loss to the basis of the first 100 replacement shares, which are those purchased on March 1. So the basis of those shares becomes $3,100 ($2,400 plus the $700 disallowed loss). You also get to extend the holding period for those shares by the Dec. 2, 2018, through March 27, 2019, holding period of the 100 shares for which the loss was disallowed.

Mutual fund shares

The wash-sale rules apply equally to losses from sales of mutual fund shares held in a taxable account. In fact, wash-sales are quite likely to apply if you have arranged for automatic reinvestment of your dividends. Again, the disallowed loss is added to the basis of the replacement shares purchased within the forbidden 61-day period.

This story was updated on March 8, 2019.