The last step is to look out for the applicability of the "wash sale" rule.
If you repurchased the stock (or "substantially identical" stock) within thirty days before or after you sold it at a loss, you are not allowed to claim the loss on the sale. Losses incurred during this 61-day window must be added to the cost basis of the stock you bought the second time.
Wash sales are actually more common than you would think, due to dividend reinvestments. If you sell a stock at a loss that has a trailing dividend posted less than 30 days after the date of sale, or if you sell a mutual fund at a loss that has a dividend that reinvested less than 30 days before the sale, you have a wash sale situation.
Here's an example of how the "wash sale" rules work:
You bought 100 shares of IBM Corp on 4/4/2004 at $60.00 per share, for a total cost of $6,000.00. On 7/7/2007, you sold 100 shares at $50.00 per share for total sales proceeds of $5,000.00. You then repurchased 100 shares on 8/5/2007 at $70.00 per share, at a total cost of $7,000.00.
Your capital loss of $1,000.00 on the sale of 7/7/2007 is not claimable on your 2007 tax return because you bought the same shares back less than thirty days later. The disallowed loss of $1,000.00 is added to the cost of the 8/5/2007 tax lot and your adjusted cost basis for the 100 shares is now $8,000.00.
How do you actually report this on your Form 1040 Schedule D? First, you list the sales transaction as if no wash sales rule applied. Then on the next line, write the words "wash sale" and the amount of the loss as a positive number in order to back out the loss.
You cannot get around these rules by having your spouse buy it back or by buying it in a different account, such as your IRA.
Wash sale rules do not apply to securities received in non-taxable exchanges (such as stock-for-stock mergers) or received as gifts, bequests, or divorce settlements.
Wash sales rules do apply to "short" sales (where the stock is borrowed and sold first, then purchased later to close out the short position.)
The holding period for the second purchase in a wash sale includes the holding period of the first purchase. If you sell the new stock less than one year after purchase, it might still be eligible for long-term capital gain treatment. Count the number of days during the holding period of the first purchase and tack them on (i.e. add them) to the number of days you owned the stock for the second purchase to see if the total exceeds one year.