When you sell shares, HMRC doesn’t let you choose which ones you’ve sold. There’s a strict matching order that determines the cost basis of the shares you disposed of — and getting it wrong means your tax calculation is wrong.
These rules trip up more people than any other aspect of UK Capital Gains Tax. Let’s go through each one properly, with examples that actually make sense.
Why matching rules exist
Imagine you bought 100 shares at £2 in 2020 and another 100 at £8 in 2024. You sell 100 today at £10. Which 100 did you sell?
If you could pick the £8 shares, your gain would be £200. If you’re forced to sell the £2 shares, your gain is £800. That’s a fourfold difference in tax — so obviously, HMRC doesn’t let you choose.
Before 1998, investors exploited this by “bed and breakfasting” — selling shares on Friday to crystallise a loss, then buying them back on Monday. Parliament put a stop to that, and the current matching rules are the result.
Rule 1: Same-day matching
If you buy and sell shares in the same company on the same day, the buy and sell are matched together before anything else.
There’s a subtle detail here that even many accountants miss: same-day compositing. If you make multiple buys or multiple sells on the same day, HMRC treats them as a single composited transaction. All same-day buys merge into one weighted-average buy. All same-day sells merge into one composited sell. Then the composited buy and sell are matched.
Example — multiple same-day trades:
| Time | Action | Shares | Price |
|---|---|---|---|
| 10:15 | Buy | 1,000 | £1.24 |
| 11:30 | Sell | 500 | £1.25 |
| 14:00 | Buy | 500 | £1.23 |
| 15:20 | Sell | 200 | £1.30 |
| 15:45 | Sell | 200 | £1.35 |
First, composite the buys: 1,500 shares at weighted average cost.
Total cost = (1,000 × £1.24) + (500 × £1.23) = £1,240 + £615 = £1,855
Average cost = £1,855 ÷ 1,500 = £1.2367 per share
Composite the sells: 900 shares at weighted average proceeds.
Total proceeds = (500 × £1.25) + (200 × £1.30) + (200 × £1.35) = £625 + £260 + £270 = £1,155
Match 900 sold against 900 of the 1,500 bought:
Cost for 900 shares = 900 × £1.2367 = £1,113.00
Gain = £1,155 − £1,113 = £42.00
The remaining 600 unmatched shares (1,500 − 900) go into the Section 104 pool at their proportional cost.
Without compositing — if you matched each sell individually against each buy — you’d get a slightly different answer. HMRC’s method avoids that ambiguity.
Rule 2: The 30-day rule (bed and breakfast)
After same-day matching, HMRC looks at whether you bought the same shares within the 30 days after the sale. If you did, those newer purchases are matched to the sale instead of the pool.
Key details that people get wrong:
It’s 30 days after the sale, not before. Shares bought before the sale (other than on the same day) are already in your pool — they’re not affected.
The window is exactly 30 calendar days. A purchase on day 30 counts. A purchase on day 31 doesn’t.
If there are multiple purchases within the 30-day window, the earliest one matches first.
Shares matched under the 30-day rule do not enter the Section 104 pool. They’re matched directly to the sale.
Example:
| Date | Action | Shares | Price |
|---|---|---|---|
| 1 Feb 2025 | Sell | 500 | £12.00 |
| 15 Feb 2025 | Buy | 300 | £11.50 |
| 28 Feb 2025 | Buy | 200 | £11.80 |
Both buys are within 30 days of the sale (1 Feb + 30 = 3 Mar). They match in order — earliest first.
First 300 shares: proceeds = 300 × £12 = £3,600, cost = 300 × £11.50 = £3,450. Gain: £150
Next 200 shares: proceeds = 200 × £12 = £2,400, cost = 200 × £11.80 = £2,360. Gain: £40
All 500 sold shares are matched. Total gain: £190
If you’d matched against the pool instead (say, average cost was £5.00), the gain would have been £3,500. The 30-day rule saved you significant tax here — but that’s the point. HMRC treats the “sell and rebuy” as if you essentially didn’t sell, so the gain is based on the actual price movement during the brief period you didn’t hold the shares.
Rule 3: The Section 104 pool
Everything left after same-day and 30-day matching goes to the pool. The pool is a running weighted average of all your shares in the same company (same class).
Building the pool:
| Date | Action | Shares | Price | Pool Shares | Pool Cost | Avg Cost |
|---|---|---|---|---|---|---|
| 10 Jan 2023 | Buy | 200 | £5.00 | 200 | £1,000 | £5.00 |
| 15 Jun 2023 | Buy | 300 | £6.50 | 500 | £2,950 | £5.90 |
| 20 Nov 2023 | Buy | 100 | £4.00 | 600 | £3,350 | £5.583 |
Now you sell 250 shares at £7.50 on 1 March 2025 (no same-day or 30-day match):
Cost from pool: 250 × £5.583 = £1,395.83
Proceeds: 250 × £7.50 = £1,875.00
Gain: £479.17
After the sale, the pool has 350 shares with a cost of £1,954.17 (£3,350 − £1,395.83). The average cost per share hasn’t changed — it’s still £5.583. That’s how pooling works: the average cost only changes when you buy more, never when you sell.
When multiple rules apply to one sale
A single disposal can trigger all three rules. Say you sell 1,000 shares on 5 March:
200 were bought the same day → same-day rule takes 200
300 are bought on 20 March → 30-day rule takes 300
The remaining 500 come from the pool → Section 104
Each portion gets its own cost basis and gain/loss calculation. You report the total.
Practical tips
Want to lock in a loss? Wait 31 days before rebuying. Or buy inside an ISA — that’s not caught by the 30-day rule because ISA shares are a separate holding.
Regular investors: If you invest monthly via a regular investment plan, you’re building a pool with a gradually changing average cost. The share matching rules make monthly investing quite tax-efficient, because the pool smooths out your cost basis over time.
Keep records of everything. Every buy, every sell, every fee, every stock split. HMRC can ask you to justify your calculations, and “I don’t have the records” is not a good answer. You need to keep records for at least 5 years after the 31 January deadline for the tax year in question.
If tracking all this manually sounds like a headache, TaxBull does it automatically. Upload your broker’s CSV export, and it applies all three matching rules in the correct order — including same-day compositing, which most other tools get wrong. Every disposal shows which rule was applied and which acquisition it was matched to, so you have a complete audit trail.
This content is for informational purposes only. Always check your specific situation with a qualified tax professional.
Free HMRC-compliant calculator with SA108 output. Supports Robinhood UK, Trading 212, Freetrade, and more.
Calculate CGT Free →
Leave a Reply