The Wash-Sale Rule
The wash-sale rule (IRC Section 1091) is the critical constraint on tax-loss harvesting. It prohibits claiming a capital loss if you buy a "substantially identical" security within 30 days before or after the sale. If you violate the rule, the loss is disallowed — not lost permanently, but added to the cost basis of the replacement shares (deferring it rather than eliminating it).
The 30-day window runs in both directions: selling a security and immediately repurchasing it triggers the rule. If you sell shares of a fund on December 15 at a loss and repurchase the same fund on January 5, the wash-sale rule applies even though the repurchase occurred in the following calendar year. Planning around year-end requires care.
The rule applies across accounts — if you sell in a taxable account and your spouse buys the same security in an IRA within 30 days, the wash-sale rule applies. It also applies if you buy the replacement shares before selling the loss position — the 30-day lookback extends into the past, not just the future. The disallowed loss is added to the basis of the newly purchased shares, preserving it for eventual recognition.
"Substantially identical" is not precisely defined in the statute or regulations, and the IRS has offered limited guidance. Switching between an S&P 500 index fund from one provider to another is generally considered safe, as is moving from a total market fund to a large-cap fund. Switching between two funds tracking the exact same index from different providers sits in a grayer area, though most practitioners treat it as acceptable given that the funds are legally distinct instruments.