Wash sales can be confusing! At a basic level, it seems clear that if you sell stock at a loss, then buy it back within 30 days, you don't get to deduct the loss. But, there are a lot of wrinkles in the wash sales rules.
According to Internal Revenue Code section 1091(a), "In the case of any loss claimed to have been sustained from any sale or other disposition of shares of stock or securities where it appears that, within a period beginning 30 days before the date of such sale or disposition and ending 30 days after such date, the taxpayer has acquired ... substantially identical stock or securities, then no deduction shall be allowed..."
Let's look at the pertinent phrases: "beginning 30 days before ... and ending 30 days after..."
Beginning 30 days before:
To illustrate this rule, let's say that you want to hold 100 shares of stock A. You think it's a good long- term hold, but it might decline in value before it goes up. So, you buy 200 shares on March 1, 2011 at a price of $50 per share. On March 20, 2011, the stock has declined to $40 per share. You sell 100 shares, recognize a loss of $1,000 and keep 100 shares at $50 per share, right? Wrong! Because you kept 100 shares that were bought within 30 days, you are not allowed to claim the loss. Instead, your basis in the remaining 100 shares is $60 per share, or $6,000.
What if you sold all 200 shares on March 20, 2011 and did not replace them for more than 30 days? You could deduct the loss. Why? Because you realized an economic loss and did not hold substantially identical shares after the sale.
What if you sold 150 shares? You would have a wash sale to the extent of 50 shares. The basis in your remaining 50 shares would be $60 per share (the $50 originally paid plus $10 disallowed loss).
Ending 30 days after:
Let's say that you've owned 500 shares of mutual fund B for 2 years. You paid $10 per share. On April 1, 2011, you sell all 500 shares at $5 per share. Then, you purchase another 500 shares of fund B on April 19, 2011 for $4 per share. The entire loss on the sale is disallowed. Your new basis in the 500 shares is $9 per share (the $10 originally paid less the $5 received plus the $4 paid on repurchase).
The bottom line:
For loss sales, you must look back 30 days if all shares of the particular (or substantially identical) security were not sold and you must look forward 30 days if any of the particular (or substantially identical) security is purchased.