As an investor you need to keep track of how much you gain (or lose) on stock transactions, both as part of managing your portfolio and for tax purposes. Stock gain is defined as the amount left over after deducting all costs (including the purchase price) from the total of all proceeds from the sale of shares plus any income they earned. Don’t forget to keep track of which money is dividend income and which comes from stock appreciation because the latter may qualify for lower capital gains tax rates.
Things You'll Need
 Stock transaction records

Compute the cost basis for the stock trade. Cost basis consists of the original (purchase) price of the stock plus all fees and commissions paid for the purchase and sale of the stock. For example, if you bought 100 shares of a stock at $10/share ($1,000) and paid fees of $10 when you bought the stock and $12 to sell it, your cost basis is $1,000 plus $10 plus $12 for a total of $1,022.

Calculate the total proceeds. Your total proceeds include the money received from selling the stock plus the cash value of dividends received while you owned the shares. For instance, if you sold the 100 shares from Step 1 for $15/share ($1,500) and received a total of $50 in dividend income during the time you held the shares, your total proceeds are $1,500 plus $50, or $1,550.

Calculate stock gain or loss. Subtract the cost basis from total proceeds. If your cost basis is $1,022 (Step 1) and total proceeds are $1,550 (Step 2) your stock gain is $1,550 minus $1,022, which equals $528. If you get a negative number (meaning the cost basis is greater than total proceeds) you had a loss rather than a gain.

Figure your percentage gain or loss. It’s usually most useful to compare percentage gain or loss to see how well different investments have done. To convert stock gain into percentage stock gain, divide the stock gain by the cost basis and multiply by 100. In the example above, you would divide $528 (stock gain) by $1,022 (cost basis) and multiply the result by 100 to get a percentage stock gain of 51.7 percent.
Tips & Warnings
 It’s not uncommon to buy shares of stock in small amounts over a period of time and then sell the shares all at the same time. You will need to total the purchase price and fees for each stock purchase and then add in sales fees to figure your cost basis.