Finlaa
Loans

Capital Gains Tax on Shares: How to Calculate What You Owe Without Losing Your Mind

30 July 2026

Capital Gains Tax on Shares: How to Calculate What You Owe Without Losing Your Mind

Capital Gains Tax on Shares: How to Calculate What You Owe Without Losing Your Mind


It is usually around 11:30 PM when you finally open the spreadsheet.

You sold a parcel of shares a few weeks ago—maybe to lock in a win, maybe because you needed the cash for something real—and now you are staring at a string of trade confirmation emails. Buy date, sell date, execution price, foreign exchange rates, transaction fees. Your broker's dashboard gives you a nice green percentage for your total return, but it completely ignores the awkward question sitting in the back of your mind: how much of this actually belongs to the taxman?

If you are currently feeling that mild knot in your stomach—the one that comes from trying to untangle multiple purchases of the same company's stock bought at different prices over three years—take a breath. Capital Gains Tax (CGT) on shares feels like an arithmetic puzzle designed by someone who hates you, but once you break it down into the actual rules, it is surprisingly mechanical.

Let's walk through how it works, how the rules actually treat your trades, and how to figure out your exact numbers so you can close the spreadsheet and finally get some sleep.

Why Your Broker's P&L Statement Is Lying to You

The first trap everyone falls into is trusting the profit-and-loss (P&L) summary on their investment app.

Your app is great at telling you the difference between what you paid for a stock overall and what you sold it for overall. But tax authorities—like HMRC in the UK—do not care about your app's tidy little summary. They care about matching rules.

If you bought 500 shares of a tech company in 2021, another 300 shares in 2022, and then sold 400 shares today, which specific shares did you just sell? Did you sell the ones from 2021 or 2022?

If you get to choose, naturally you’d pick the ones you bought at a higher price to minimize your taxable profit. But the tax system does not let you cherry-pick. It operates on a strict matching sequence. And if you don't know the sequence, your calculation will be completely wrong—usually leaving you overpaying or frantically scrambling when a tax return is due.

To see how these moving parts actually fit together, let’s follow someone through the process.

Meet Sarah and Her Tech Portfolio

Let’s look at Sarah. Sarah lives in the UK and works in marketing. Back in 2022, she started buying shares in a renewable energy company listed on the London Stock Exchange.

Here is Sarah’s trading history for this particular stock:

  • May 2022: Bought 400 shares at £4.00 each (£1,600 total, plus £10 trading fee)
  • November 2022: Bought 600 shares at £5.50 each (£3,300 total, plus £10 trading fee)
  • August 2023: Sold 500 shares at £8.00 each (£4,000 total, minus £15 trading fee)

Sarah opens her broker statement and thinks her gain is simply £4,000 minus what she paid. But HMRC’s share identification rules—often called the "share pooling" or "Section 104" rules—are going to look at this very differently.

Before we calculate what Sarah owes, it helps to understand the order of operations the tax authority expects you to follow.

The Three Rules of Matching (How HMRC Sorts Your Trades)

When you sell shares, you cannot just use whatever math is convenient. You have to run your trades through a specific hierarchy. Think of it as an invisible sorting machine:

  1. The Same-Day Rule: Any shares bought and sold on the exact same calendar day are matched against each other first. (If Sarah bought and sold shares on August 3rd, those match up instantly).
  2. The 30-Day Rule (Bed and Breakfasting): If you buy shares within 30 days after selling them, those newly bought shares are matched against the ones you just sold. This stops people from selling shares to trigger a loss and immediately buying them back just to lock in a tax break.
  3. The Section 104 Holding (The Pool): Everything else goes into a giant metaphorical blender called a share pool.

For Sarah’s sale in August 2023, she didn't buy any shares on that same day, nor did she buy any within 30 days after the sale. That means her sale falls straight into the Section 104 Pool.

This is where things get interesting—and where most DIY investors get stuck.

Step-by-Step: Working Out Sarah’s Pool and Allowable Cost

A Section 104 holding isn't a list of individual purchases. It is a running average pool of all your shares of that specific company, lumped together with a blended average cost.

Let’s build Sarah’s pool step by step:

1. Tally up the initial purchases (including costs)

  • Purchase 1: 400 shares at £4.00 = £1,600 + £10 fee = £1,610
  • Purchase 2: 600 shares at £5.50 = £3,300 + £10 fee = £3,310
  • Total Pool So Far: 1,000 shares for a total allowable cost of £4,920

2. Calculate the average cost per share

Divide the total cost by the total number of shares: $$\frac{£4,920}{1,000 \text{ shares}} = £4.92 \text{ per share}$$

Notice that her average cost is £4.92, even though she bought her first batch at £4.00 and her second at £5.50. The pool smooths it all out.

3. Calculate the cost of the shares she sold

In August 2023, Sarah sold 500 shares. Under the pooling rules, those 500 shares are considered sold at the pool's average cost of £4.92 each.

  • Allowable Cost for Sale: $500 \text{ shares} \times £4.92 = £2,460$

4. Calculate the gross disposal proceeds

She sold 500 shares at £8.00 each, minus a £15 selling fee:

  • $(500 \times £8.00) - £15 = \mathbf{£3,985}$

5. Find the capital gain

Subtract the allowable cost from the net proceeds: $$\text{Gain} = £3,985 (\text{Proceeds}) - £2,460 (\text{Cost}) = \mathbf{£1,525}$$

Just like that, Sarah’s capital gain on the trade is £1,525. Not £4,000, not whatever her app guessed—precisely £1,525 once purchase costs, selling fees, and pooling rules are accounted for.

If you want to run these numbers quickly for your own portfolio without building a manual spreadsheet, you can use tools like our free Mortgage Calculator equivalents or dedicated financial estimators to help check your math.

The Trap Door: What Trips People Up

Even when you understand the pooling rules, a few classic edge cases routinely catch people off guard. Keep these in mind before you finalize your numbers:

1. Forgetting Transaction Fees

Broker commissions, platform fees, and stamp duty are not just annoying costs—they are your friends when it comes to tax. Legally, any costs you pay to acquire shares get added to your cost base, and any costs you pay to dispose of them get subtracted from your proceeds. Lower proceeds and higher costs equal a smaller capital gain. Never leave them out.

2. Currency Conversion Headaches

If you trade US stocks (like Apple or Tesla) through a UK broker while your base currency is British Pounds, every single transaction must be converted to GBP using the exchange rate on the exact day the transaction occurred. You cannot just use today's exchange rate, and you cannot use a yearly average. If you bought shares over a three-year period, you might be dealing with three different exchange rates for the same stock pool.

3. Spouses and Civil Partners

If you transfer shares to your husband, wife, or civil partner, it is generally treated as happening at "no gain, no loss." That means the tax clock doesn't reset—they inherit your original purchase price and your original acquisition date. This can be a brilliant tool for utilizing two sets of tax-free allowances, but only if you track the original history properly.

The Tax-Free Allowance and What You Actually Owe

Once you have calculated your total capital gain across all your share sales for the tax year, you reach the part of the process that brings the actual relief: allowances.

In the UK, every individual has an annual Capital Gains Tax allowance (the Annual Exempt Amount). If your total net gains across all assets (shares, second properties, crypto) stay below that threshold in a given tax year, you owe £0 in tax. You don't even need to report it to HMRC unless your total sales exceed a separate reporting threshold (usually four times the allowance amount).

If your gains do exceed the annual allowance, the tax you pay depends on your overall income tax bracket:

  • Basic rate taxpayers: Pay a lower percentage on gains above the allowance (historically 10% on most assets, or 18% on residential property).
  • Higher and additional rate taxpayers: Pay a higher percentage (historically 20% on most assets).

Let's return to Sarah. Suppose her total taxable gain for the year is £1,525, and her annual tax-free allowance is available in full. Because her gain is below the allowance threshold, her tax bill is £0. She doesn't owe a penny. Even if she had other gains that pushed her over the line, she would only pay tax on the slice above the allowance, not the whole amount.

How to Make Next Year's Calculation Take Five Minutes

If staring at this math has convinced you that investing is too much paperwork, don't throw in the towel. You don't have to live in fear of spreadsheet season. You can fix this at the source with three simple habits:

  • Export your CSVs as you go: Don't wait until tax season to log into your broker. Download your transaction history (CSV or Excel format) at the end of every quarter while the data is fresh.
  • Keep a running pool tracker: If you buy the same stock repeatedly, maintain a simple note of your current Section 104 pool share count and total allowable cost. Every time you buy more, update the average.
  • Leverage tax wrappers: The absolute best way to eliminate share CGT is to stop paying it in the first place. If you are maxing out your tax-advantaged accounts (like ISAs in the UK or equivalents elsewhere), any capital gains you make inside those wrappers are entirely tax-free, forever. No pooling rules, no spreadsheets, no 11:30 PM panic.

You Are Closer Than You Think

Calculating capital gains on shares feels intimidating because it forces you to look backward across every decision you made with your money over the last few years. It feels like a test of your financial discipline.

But it is just arithmetic. Once you know that your broker app's summary isn't the final word, that transaction fees work in your favor, and that your gains are measured against a clear annual threshold, the fog starts to clear.

Take it one trade at a time, log your costs, and let the rules do the heavy lifting. You've got this.


Disclaimer: This article is for general informational purposes only and does not constitute formal financial, tax, or legal advice. Tax laws change, and individual circumstances vary. If you have a complex portfolio or substantial gains, consider speaking with a qualified tax professional or accountant.

For quick estimates on loans, savings, and financial planning while you're on the move, check out the free Finlaa app.

Frequently Asked Questions

Do I have to pay Capital Gains Tax if I sell shares and leave the cash sitting in my broker account?

Yes. The taxable event happens the moment you sell the shares (the contract date), not when you withdraw the cash to your bank account. Even if you plan to buy different shares the next day, selling the original stock triggers the gain or loss for that tax year.

What happens if I make a capital loss on my shares?

Losses are your friend. If you sell a parcel of shares for less than you paid for them, you can offset that loss against any gains you made elsewhere in the same tax year. If your total losses outweigh your gains, you can even carry those unused losses forward to reduce your tax bill in future years—provided you register them with your tax authority within the required window.

Are dividends subject to Capital Gains Tax?

No. Dividends (payments companies make to you out of their profits just for holding the stock) are taxed under an entirely different set of rules called Dividend Tax. CGT only applies when you actively dispose of (sell) the asset for a profit.

Related calculators

Related articles