9th Dimension Digital Ltd

How to calculate capital gains on shares in the UK (same-day, 30-day and Section 104 rules)

General information, not tax, legal or investment advice. Not affiliated with, endorsed by or approved by HMRC or the UK Government. Sources read on 24 November 2026.

Short answer: when you sell shares in a company you also bought at other times, HMRC does not let you pick which ones you sold. Shares of the same class in the same company are treated as identical, so rules decide which purchase each sale is matched to (HMRC Capital Gains Manual, CG51500). The order is same day first, then the 30 days after the sale, then the Section 104 holding (CG51560).

The three rules, in order

  1. Same-day rule. If you buy and sell the same class of shares on the same day, the sale is matched with that day’s purchase first. Any shares sold beyond the number bought that day are matched under the other rules (CG51560).
  2. 30-day rule (HMRC’s guidance also calls it “bed and breakfasting”). A sale is matched with shares you buy within the 30 days after it. A purchase 31 days after the sale is outside the window (CG51560, examples 1 to 3).
  3. Section 104 holding. Everything left is matched against one pool of the same class of shares. The pool is treated as a single asset with a single pool of cost. When you sell part of it, the cost is shared out by the number of shares sold (CG51575; worked examples in CG51590). In practice the number of shares sold can be used for this; CG51575 gives the strict formula.

Some shares have their own special rules, for example shares with a deferral claim under the Enterprise Investment Scheme (CG51500). The example below does not cover those.

A worked example (made-up numbers)

“Example plc” is a fictional company. All prices and dates are invented, and dealing costs are ignored to keep the sums short.

Date Action Shares Price Amount
1 June 2020 Buy 1,000 £2.00 £2,000
1 March 2023 Buy 250 £3.00 £750
10 June 2025 Sell 600 £5.00 £3,000
10 June 2025 Buy 100 £4.80 £480
20 June 2025 Buy 150 £4.50 £675

Step 1: same day. 100 of the 600 shares sold are matched with the 100 bought on 10 June 2025. Proceeds 100 x £5.00 = £500. Cost £480. Gain £20.

Step 2: 30 days. The purchase on 20 June 2025 is 10 days after the sale, so 150 more shares are matched with it. Proceeds 150 x £5.00 = £750. Cost £675. Gain £75.

Step 3: Section 104 holding. 600 – 100 – 150 = 350 shares remain. The pool from the two earlier purchases holds 1,250 shares at a total cost of £2,750 (£2,000 + £750), an average of £2.20 a share. Selling 350 removes 350 x £2.20 = £770 of cost. Proceeds 350 x £5.00 = £1,750. Gain £980. The pool then holds 900 shares with a cost of £1,980.

Rule Shares Proceeds Cost Gain
Same day 100 £500 £480 £20
30 days 150 £750 £675 £75
Section 104 350 £1,750 £770 £980
Total 600 £3,000 £1,925 £1,075

The total gain for this sale is £1,075. The two purchases that were matched to the sale (100 and 150 shares) do not join the pool. The 10 June sale falls in the 2025 to 2026 tax year, which runs from 6 April 2025 to 5 April 2026. Real cases add dealing costs, stamp duty, several sales, share splits and more, and each changes the figures.

What GOV.UK says about reporting

  • Annual exempt amount. GOV.UK lists a Capital Gains Tax allowance of £3,000 for individuals (GOV.UK, Capital Gains Tax allowances). Check the figure for your tax year.
  • The £50,000 rule. If you are registered for Self Assessment, you must report gains if your total sale proceeds are over £50,000, for the 2023 to 2024 tax year onwards (GOV.UK, work out if you need to pay Capital Gains Tax). The test uses proceeds, not gains.
  • Where it goes. Gains and losses on shares go on the Capital Gains Tax summary pages of the Self Assessment return, SA108 (GOV.UK, SA108 form and notes). In our product notes for 2025 to 2026, listed shares and securities use boxes 23 to 27 and unlisted shares and securities (for example AIM shares) use boxes 31 to 35. Box numbers change between years, so check the form for your year.
  • Deadline. For the 2025 to 2026 tax year, the online return and the payment are both due by 11:59pm on 31 January 2027 (GOV.UK, Self Assessment deadlines).
  • Helpsheet. HMRC’s helpsheet HS284 covers how to identify the shares sold, the bed and breakfasting rule and the Section 104 holding, and has a 2025 to 2026 edition (GOV.UK, HS284).

Want a version to fill in?

The Share CGT Calculator and Portfolio Tracker (UK) is an Excel* and Google Sheets* workbook. You enter your trades from your contract notes. It applies the same-day, 30-day and Section 104 matching to each sale in a general investment account, and sets out the totals against the SA108 boxes for listed and unlisted shares. It includes a filled example with made-up data. It was tested against HMRC’s own worked examples in CG51590 and CG51560 and in HS284.

It is a record-keeping and calculation tool. It is not tax or investment advice, it does not work out your tax bill, it does not file your return and it never suggests buying, selling or holding anything. It does not cover crypto, options, CFDs, share consolidations, returns of capital, takeovers and some other cases (full list on the product page).

Where to buy it

On Gumroad: UK buyers pay £14.40 in total: £12 + £2.40 VAT, added at checkout by Gumroad (the seller of record). Outside the UK, local VAT or sales tax may apply. Your legal rights are not affected: if a file is faulty, won’t open or is not as described, email [email protected] and we will repair or replace it, or give a full or partial refund if we can’t. It is an instant download. At checkout you ask for delivery to start straight away and confirm that you then lose your 14-day right to cancel, so we do not refund for change of mind once the download is available.

FAQ

Can I choose which shares I sold? Not for shares of the same class in the same company. The matching rules above decide (CG51500 and CG51560, linked above).

Do ISA and pension holdings count? Our product keeps them outside the Capital Gains Tax figures. Check HMRC guidance for your own case.


This is general information, not tax, legal or investment advice, based on GOV.UK pages read on 24 November 2026. The example uses a fictional company and made-up numbers. Dates, rates and box numbers can change: check GOV.UK and the form for your tax year. HMRC and GOV.UK are named only to say where the rules come from. 9th Dimension Digital Ltd is not affiliated with, endorsed by or approved by HMRC or the UK Government.

*Microsoft and Excel are trademarks of the Microsoft group of companies. Google Sheets is a trademark of Google LLC. 9th Dimension Digital Ltd is not affiliated with, or endorsed by, Microsoft or Google.

Written by 9th Dimension Digital Ltd with AI-assisted tools, and checked against the sources linked above.

Scroll to Top