If you sell an investment such as a stock or mutual fund in a taxable investment account, then you might have to pay capital gains taxes on any profit that you make. This does not apply to a tax-deferred retirement accounts such as 401(k) plan and Roth IRAs.

If you make a profit on the investment then you will have a capital gain which is taxable. If you lose money, then you will have a capital loss which is not taxable but can be used to offset capital gains if you have any.

### Capital gain

A capital gain is the difference in the selling price of an investment and the purchase price minus transaction costs, if you sell for a higher price than you bought it at.

For example, let’s say you bought a mutual fund on the advice of the genius kid next door for $5,000 with a transaction cost of $50 and then sold it for $7,000 with a transaction cost of $50. Since your selling price is higher than your purchase price, this will result in a capital gain.

To calculate the capital gain, you subtract the purchase price and transaction costs from the sale price.

Capital gains = sale price – purchase price – transaction costs

= $7,000 – $5000 – $100

= $1,900

### Capital loss

What happens if the hot stock tip you heard at the coffee shop turned out to be a dud and you lost money? In that case you will have a capital loss because you sold the stock for less than you paid for it.

For example if you buy an investment for $10,000 with a transaction cost of $25 and sell it for $9,200 with a transaction cost of $25.

Capital loss = sale price – purchase price – transaction costs = $9,200 – $10,000 – $50 = -$850.

You might notice that the formula is the same for both losses and gains. If the answer is negative then you have a capital loss. If the answer is positive then you have a capital gain.