Whether you're rebalancing your portfolio, capturing a capital gain or dumping a losing stock, it's easy to forget that taxes have an impact on exactly what you'll take home from that stock sale. Even when you do remember, it may be difficult to determine exactly what you'll pay, and where that number comes from. In stocks, everything goes back to when you bought it and how much you paid for it.
The cost basis is the amount of money you paid for a stock, and it is the number you'll use to calculate any gain or loss. If you bought all your shares at once, or you sold them all at once, the calculation is easy; it's simply the total of what you paid for the stock plus any commissions and brokerage fees related to the trades. If you purchased your shares at different times, and do not sell them all at once, you must calculate your cost basis for each of these lots separately.
If you do have multiple lots, you can choose which ones you want to sell. If you pick and choose, it's known as the "specific share identification" method. You need to coordinate with your brokerage firm to ensure that they sell and report the correct lots. The IRS defaults to the last-in-first-out method so you'll sell your oldest lots first.
Short vs. Long Term
When you select the lots you want to sell, you should also consider the holding period. If you hold stocks for more than 12 months before selling them, you qualify for the discounted long-term capital gains tax. The money you make on securities you hold for a year or less is considered a short-term gain, which is taxed at the ordinary tax rate.
If you lose money on your sale you have a capital loss. You can use up to $3,000 worth of your losses per year to offset your capital gains and lower the total taxable amount. If you have more losses than you have gains, or losses over $3,000, you can carry them over to future years.