Wash Sale Rule
The buying and selling of stock 30 day rule is commonly known as the “wash sale” rule. The rule originated with the Internal Revenue Service – IRS – to stop investors from taking tax deductible stock market losses by selling losing positions and then buying back the same shares to keep the investment in the investors' portfolios.
The basic rule of the wash sale rule is that if an investment is sold for a loss and the same investment is purchased within a window 30 days before or after the sale, the loss will be disallowed as a capital loss tax deduction.
Wash Sale Gotcha’s
The wash sale rule sounds simple: Sell a stock, or other investment, for a loss and don’t buy the stock again for at least 30 days. The problems come in with the more exact wording of the rule. An investor cannot buy a substantially identical equal security within the plus or minus 30 day rule. If an investor likes an investment, but needs the tax loss, she will be looking for a way to quickly replace the sold investment.
There are several ways an investor can run afoul of the substantially identical part of the rule. Mutual funds with the same holdings will trigger a wash sale. This can easily happen with index funds. If an investor sells the Vanguard S&P 500 index fund for the loss and the next day buys the Fidelity S&P 500 index fund, a wash sale has occurred.
Purchasing options for the purchase of the sold security within the 30 day window will turn the loss into a wash sale. A pending merger can also turn a loss into a wash sale. If the investor sells a stock that will soon merge with another company and then buys shares in the stock on the other side of the merger, the IRS will considered the two stocks to be substantially linked and disallow the loss deduction.
See this article for some examples of wash sales.
The Loss is Not Lost and other Interesting Items
If a capital loss on a security is disallowed due to the wash sale rule, the loss is not lost. The disallowed loss amount will be added to the basis of the security purchased as the replacement. When the replacement security is sold at some point in the future, the added in loss will reduce the capital gain amount or increase the size of the loss realized at the time of that sale.
To get around the wash sale rule, and not be out of the market in case prices take off, an investor has to be creative around the substantially identical clause. The investor should look for investments that are close but not the same. For example, Hewlett Packard stock could be sold for a loss and Dell purchased as a replacement. The S&P 500 index fund is sold for a loss and an actively managed mutual fund owning large cap companies could be bought as the replacement.
Finally, because taxes cannot be avoided, there is no wash sale rule for investments sold for a gain. Sell a stock for a big gain and buy the shares back the next day and you will still be responsible for paying taxes on the gain.
Tax Guide for Investors: Wash Sale Rule https://www.fairmark.com/capgain/wash/index.htm
Smart Money: Understanding the Wash Sale Rules https://www.smartmoney.com/personal-finance/taxes/understanding-the-wash-sale-rules-9860/