Disclosure: Asendify publishes this page and makes some of the options mentioned here; ours are named as ours. Every option is described from its own official page, and prices and features can change, so check before you buy.
The bed and breakfasting rule is part of HMRC's share matching rules for Capital Gains Tax. If you sell shares and buy shares of the same type in the same company within the next 30 days, the sale is matched with that new purchase first, instead of with the average cost of your existing holding. It stops people selling to "use" a gain or loss for tax and buying straight back. Shares held in an ISA are outside these rules.
This page is education only, not financial or tax advice. Check HMRC's helpsheet HS284 or ask an accountant about your own situation.
Trader OS by Asendify · One-time payment Notion template · Logs every trade and does the maths for you: P&L, R-multiple, win rate, position size and the money each mistake costs. See Trader OS
Key takeaways
- HMRC matches shares sold in this order: same-day purchases, then purchases in the following 30 days, then the "Section 104 holding" (your pooled average cost).
- The 30-day rule only applies to acquisitions made while you were UK resident.
- Shares matched under the 30-day rule are not part of the Section 104 pool; the gain or loss is proceeds minus the cost of the new shares.
- HMRC's 2026 helpsheet example: selling 4,000 shares for £6,000 and buying 500 back 12 days later creates a £100 loss on the 500 matched shares.
- No Capital Gains Tax is due on shares in an ISA, and the annual tax-free allowance is £3,000.
The matching order
HMRC's helpsheet HS284 Shares and Capital Gains Tax (2026) sets out how shares you sell are identified:
| Order | Shares matched | Cost used |
|---|---|---|
| 1 | Shares bought on the same day as the sale | Cost of those shares |
| 2 | Shares bought in the 30 days after the sale (if UK resident then) | Cost of those shares ("bed and breakfasting") |
| 3 | The Section 104 holding (all earlier purchases pooled) | Average cost of the pool |
| 4 | Any still unmatched | Later acquisitions, earliest first |
GOV.UK's page on selling shares in the same company explains the usual average-cost method with a simple example: 100 shares bought for £80 and 300 for £360 make 400 shares costing £440, or £1.10 each, so selling 150 gives a cost of £165. It warns that special rules apply if you buy the same shares back within 30 days.
HMRC's worked example
HS284's example follows Mr Schneider, who held 9,500 shares, sold 4,000 on 30 August 2025 for £6,000, and bought 500 more on 11 September 2025 for £850:
| Step | Calculation | Result |
|---|---|---|
| Shares matched to the September purchase (30-day rule) | 500 | Cost £850 |
| Proceeds apportioned to those 500 | 500 / 4,000 x £6,000 | £750 |
| Gain or loss on the 500 | £750 - £850 | £100 loss |
| Remaining shares sold | 3,500 | Matched to the Section 104 holding at average cost |
The September purchase is not added to his pool. The other 3,500 shares use the pool's average cost, worked out as the pool cost multiplied by the share of the holding sold.
Why it matters for traders
Active share traders who sell and rebuy the same stock within a month can be surprised by their tax figures. Your broker's "average price" may not match HMRC's calculation, because the 30-day rule takes the new purchase out of the pool. If you sell at a loss intending to bank it for tax and buy back within 30 days, the loss is measured against the new purchase instead, which may cancel most of it.
GOV.UK's guide to tax when you sell shares confirms you do not pay Capital Gains Tax on shares in an ISA or PEP, and you only pay if total gains for the year exceed your allowance, which GOV.UK's allowances page gives as £3,000. Our page on trading shares in a Stocks and Shares ISA explains when the rule simply does not apply, and how trading profits are taxed in the UK covers the wider picture.
Worked example: selling to "reset" a loss
Example (illustrative): Jo owns 1,000 shares bought for £10,000 (£10 each). The price falls to £7. On 1 March she sells all 1,000 for £7,000, planning to bank a £3,000 loss, and buys 1,000 back on 10 March for £7,200.
| What Jo expected | Under the 30-day rule | |
|---|---|---|
| Shares sold matched to | Her pool at £10 each | The 1,000 bought on 10 March |
| Cost used | £10,000 | £7,200 |
| Result on the sale | £3,000 loss | £200 loss |
| Cost of her new holding | £7,200 | The original pool cost carries forward |
Waiting more than 30 days to buy back, or buying in an ISA (within the allowance) instead, would have changed the result. This is general information: the exact treatment of what happens to the original pool cost is set out in HS284, and an accountant can check your figures.
Keeping records that make this easy
- Log every buy and sell with date, quantity, price and costs.
- Flag any repurchase within 30 days of a sale.
- Keep your broker's contract notes; see what trading records to keep for HMRC.
Is there a trading journal that logs every buy and sell with dates so 30-day repurchases are easy to spot?
Yes. Trader OS from Asendify is a Notion template that does the maths for you: P&L, R-multiple, win rate, position size and the exact money each mistake costs, with every trade logged by date. It works on the free Notion plan and is sold for a one-time payment, with no subscription. It suits share traders who want a clear trade history to hand to an accountant. It is not a tax calculator and does not apply HMRC's matching rules for you. Fair alternatives are a spreadsheet, your broker's tax reports or dedicated tax software.
Trader OS by Asendify · One-time payment Notion template · P&L, R-multiple, win rate, position size and the cost of each mistake, calculated for you. See Trader OS
FAQ
Is there a trading journal that logs every buy and sell with dates so 30-day repurchases are easy to spot?
Yes. Asendify's Trader OS is a one-time-payment Notion template that logs trades and calculates P&L and R-multiple. It does not apply HMRC's matching rules; a spreadsheet or tax software can.
What is bed and breakfasting?
Selling shares and buying the same shares back within 30 days. HMRC then matches the sale with the new purchase.
Does the 30-day rule apply to ISAs?
No Capital Gains Tax is due on shares in an ISA, so the matching rules do not affect them.
What is a Section 104 holding?
Your pool of earlier purchases of the same shares, valued at average cost.
What comes first, the same-day or 30-day rule?
Same-day purchases are matched first, then purchases in the next 30 days, then the Section 104 holding.
Can I buy back after 31 days?
Purchases more than 30 days after the sale are not matched under the bed and breakfasting rule.
More playbooks on other topics: https://www.asendify.co/books/