A wash sale occurs when a taxpayer sells a security at a loss and buys a substantially identical security within thirty calendar days before or after the sale. The 30-day rule applies even if the sale and purchase occur in different years—a sale on December 31 and repurchase on January 1 still counts as a wash sale.
Securities include stocks, bonds, exchange-traded funds, mutual funds, and derivatives of securities such as stock options. Sales of cryptocurrencies are a grey area because the IRS has not included cryptocurrencies in wash sale rules as of the date of this article.
Substantially identical also lacks a comprehensive definition. Publication 550 expresses the IRS's unofficial opinion that securities of different corporations generally don't meet the substantially identical test. Selling Walmart stock and immediately buying Target stock probably won't cause a wash sale despite the similarities between the companies.
The IRS also believes that different types of securities from the same company usually won't trigger a wash sale. However, securities that convert into a substantially identical security—most commonly stock options—will cause a wash sale. Wash sale rules probably don't apply to selling Walmart common stock and immediately buying a Walmart nonconvertible bond. Purchasing Walmart stock options instead of a bond constitutes a wash sale because stock options can convert into common stock.