How the rule works
Under this rule, if you sell stock or securities for a loss and buy substantially identical stock or securities back within the 30-day period before or after the sale date, the loss can’t be claimed for tax purposes.
The rule is designed to prevent taxpayers from using the tax benefit of a loss without parting with ownership in any significant way. Note that the rule applies to a 30-day period before or after the sale date to prevent “buying the stock back” before it’s even sold
Keep in mind that the rule applies even if you repurchase the security in a tax-advantaged retirement account, such as a traditional or Roth IRA.
Although the loss can’t be claimed on a wash sale, the disallowed amount is added to the cost of the new stock. So, the disallowed amount can be claimed when the new stock is finally disposed of (other than in a wash sale).
If you’ve realized gains in 2019, you may be looking for unrealized losses in your portfolio so you can sell those investments before year end. By doing so, you can offset your gains with your losses and reduce your 2019 tax liability. But don’t run afoul of the wash sale rule.