Knowing the amount of money you invested in a stock can help you hold on to more of a gain or make the best of a loss. By Susan B. Garland, Contributing Editor November 18, 2010 EDITOR'S NOTE: This article was originally published in the October 2010 issue of Kiplinger's Retirement Report. To subscribe, click here.The time will come when you want, or need, to sell shares of stock or a mutual fund to raise cash or move to a new investment. You can hold onto more of any gain, or make the best of any loss, if you keep an eye on the tax consequences of the sale. That means knowing your cost basis. Your cost basis is your investment in the asset. You compare this amount to the proceeds of the sale to know if you have a taxable capital gain or a tax-saving capital loss. Sounds simple, but tracking your basis can be mind-numbingly complex. What if your stock has a tangled history of corporate spinoffs or splits? Or perhaps you bought shares at different times at different prices. Each batch can have a different basis, which guarantees a different tax result when you sell. Advertisement Your basis depends in part on how you got the stock. If you bought it, your basis begins at your original price plus any commissions. Say you bought 100 shares of Acme Co. at $30 a share, and you paid $100 in commissions. Your total cost is $3,100, so your per-share basis is $31. If you sell all the shares for $50 each and pay $200 in commissions, you have a $1,700 taxable gain (the $4,800 after-commission sales proceeds minus the $3,100 basis). If you've held the stock for more than a year, you'll owe long-term capital-gains tax of up to 15% on the profits. If you've held the stock for one year or less, you will pay ordinary-income tax of up to 35%. The basis of inherited securities is figured differently. There's a special rule for assets inherited in 2010. In the past -- and in the future, according to a law that's scheduled to go into effect January 1, 2011 -- the basis of inherited assets is "stepped up" to their value on the day the previous owner died. So if Dad left you shares of XYZ Co. in 2009, your basis is the value of those shares on the day he died. Any profit that built up during his lifetime is tax-free. (But you don't inherit a tax-saving loss if the value declined during the previous owner's life.) For property inherited in 2010, there's a limit to how much appreciation can be wiped out by the step-up rule. The executor of the estate can step up the basis $1.3 million, plus an extra $3 million for assets left to a surviving spouse. Say your mother died this year and left you shares worth $2 million that she bought for $200,000. If you sell, you can add another $1.3 million in basis and pay tax on $500,000 in profit. If an estate holds assets with $1.3 million or less of appreciation, heirs follow the same step-up rule as in the past. Advertisement The basis of shares received as a gift will be the same as the original owner's. If you sell at a profit, you'll pay tax on any appreciation since the original owner bought the stock. But if you sell at a loss, the basis is the giver's basis or the value on the date of the gift, whichever is lower. Say Aunt Jane bought stock for $800 and gave you the shares when they were worth $1,000. If you sell when the value is $600, your loss is limited to $200. If a company declares a stock split, all of your shares will get a new basis. Assume you bought 100 shares of ABC Co. for $20 a share. If the company declares a four-for-one split, you would receive 300 new shares. Your adjusted cost basis for each share you own would now be $5. The holding period for all shares begins on the day you bought the original shares. Selling the Right Shares A common mistake is losing track of reinvested dividends. When you choose to have dividends automatically reinvested, you're really buying more shares. And the basis of each one is determined by the price on the day the dividends are reinvested. Of course, the same thing goes when you buy new shares in the same company or mutual fund over a period of time: You'll end up with shares bought on different dates at different prices. When it's time to sell, you can pick higher-basis shares if you want to hold down the tax bill. Or you can choose lower-basis shares if you have losses from other transactions (or carryover losses from previous years) to sop up the taxable gain from the sale. Advertisement For selling stocks and mutual funds, you will need to follow one of the IRS-approved methods for fixing the basis of your shares: Specific identification. With this method, you direct the broker or fund to sell specific shares. Assume you bought 100 shares at $20 a share in March. In October, you buy another 100 shares for $25 a share. Three years later, the share price hits $30, and you sell 50 shares. The taxable gain will be $10 a share, or $500, if the shares come from the March lot, but only $5 a share, or $250, if you tell your broker to sell the October shares. "Specific identification is the best route because it gives you the most flexibility," says Rande Spiegelman, vice-president of financial planning for Charles Schwab. You need to identify to your broker the date you bought the shares and the price you paid. Ask for a written confirmation. For online trading, each firm handles specific identification differently, so find out ahead of time how to get written confirmation. Advertisement First in, first out. If you don't cite specific shares to be sold, the IRS's FIFO rule applies. That means the IRS assumes you sold your oldest shares first. And that can produce the biggest possible tax bill because, as Mark Luscombe, principal tax analyst for CCH, a publisher of tax information, notes, "The oldest stocks are usually your lowest-basis stocks." Average cost. There's a third option for mutual funds only. Really, there are two average-cost methods: the single and double categories. Most people use the single category. You add up everything you have invested in the fund over the years, and then divide that total by the number of shares you own. The resulting average basis per share is the value you use when figuring your gain or loss when you sell. "Typically this is better than FIFO, but it's not the best answer if the market has gone down," says Spiegelman. The most arduous job is adjusting basis if a company has undergone a series of spinoffs, splits, mergers and other actions in the years since you bought the stock. If your broker or accountant can't help, try NetBasis Services (www.netbasis.com; 888-802-2747). NetBasis has developed software that can track the change in basis for every stock and fund going back to 1925. You only need to know the year the security was purchased. "Our service can literally adjust the cost basis from the time of purchase to the point of sale," says Nico Willis, president of the Phoenix-based company. Within seconds, NetBasis will spit out a sheet showing every corporate activity since the year the stock or fund was bought. The cost for a search for one security is $19.95 and $57 for three.