Capital gains and losses: the calculation, before any question of tax
A capital gain is the profit made when you sell a security for more than it cost; a capital loss is the loss in the opposite case. The calculation seems simple, but it gets complicated as soon as you have bought in several steps, paid fees or kept part of your position. This article explains how to calculate the gain or loss on a share, the difference between unrealised and realised, and the most common pitfalls. It does not cover taxation: tax rules vary by country, account type and individual situation, and are a matter for a professional.
Unrealised and realised gains
- An unrealised gain is the theoretical profit on a position you still hold: until you sell, nothing is secured, and the amount moves with the price.
- A realised gain is the profit recorded at the time of sale: the amount is then fixed.
The same reasoning applies to losses: we speak of unrealised or realised losses.
The basic formula
Gain = (selling price − average cost per share) × number of shares sold − selling fees
The average cost per share (PRU) is the average acquisition cost of the shares, purchase fees included. To calculate it, see the PRU: definition and calculation. If the result is positive, it is a gain; if negative, a loss.
Worked example: a partial sale
Fictitious example. An investor holds 40 shares with a PRU of €47.65. They sell 15 at €55, with €3 in selling fees.
- Sale amount: 15 × 55 = €825.
- Cost of the shares sold: 15 × 47.65 = €714.75.
- Realised gain: 825 − 714.75 − 3 = €107.25.
They are left with 25 shares, still with a PRU of €47.65 if the weighted average is used. If those 25 shares then trade at €50, the unrealised gain is (50 − 47.65) × 25 = €58.75.
Why the calculation method changes the result
When you have bought at several prices and sell only part of the position, you must decide which shares are considered sold. Two conventions are common:
- The weighted average: each share sold is deemed to cost the average PRU.
- First in, first out: the oldest shares are deemed sold first, at their original purchase price.
With the same transactions, these two methods give a different realised gain at a given date, then converge when the whole position is sold. What matters is knowing which one your broker or tracking tool uses, and not comparing figures calculated differently.
Pitfalls to avoid
- Forgetting fees. Purchase fees increase the cost basis, selling fees reduce the gain. On small amounts, they weigh heavily: see the impact of brokerage fees on performance.
- Ignoring corporate actions. A stock split, a reverse split or a bonus issue changes the number of shares and the reference price: the cost basis must be adjusted, otherwise the calculated gain is wrong.
- Neglecting currency. For a share quoted in another currency, the gain in euros also depends on the change in the exchange rate: see currency risk.
- Confusing a running gain with a secured gain. An unrealised gain can disappear if the price falls before the sale.
Key takeaways
- Gain = (selling price − PRU) × quantity sold − selling fees.
- Unrealised while you hold the security, realised on sale.
- With several purchases, the method (weighted average or first in, first out) changes the gain on a partial sale.
- Fees, corporate actions and currency change the result.
- This calculation is a reading aid: it replaces neither your broker's statements nor a professional's advice on tax.
This article is for information and education only and does not constitute personalised investment or tax advice. The figures in the examples are fictitious and illustrative. It does not cover the taxation of capital gains.