Quick answer
The bed and breakfast rule, also called the 30-day rule, says that if you sell shares and buy the same shares back within 30 days, the sale is matched with the new purchase instead of your earlier holding. Your gain or loss is then worked out using the price of the repurchase. The rule stops you selling to lock in a loss or use your allowance and then buying straight back. It applies to shares, funds and cryptoassets.
Key facts
- A sale is matched with a purchase of the same shares in the next 30 days, before any pooled shares.
- The same-day rule comes first, then the 30-day rule, then the Section 104 pool.
- The rule stops quick “sell and rebuy” tricks to create a loss or use your allowance.
- It applies to shares, funds, investment trusts and cryptoassets.
- Buying back inside an ISA or through your spouse can be treated differently, but each has its own limits.
Good to know
Test your trades
Enter your purchases and sales into our Section 104 calculator. It applies the same-day and 30-day rules automatically.
What the bed and breakfast rule is
Years ago, investors would sell shares late in the day and buy the same shares back the next morning. The sale created a gain that used up their allowance, or a loss that cancelled other gains, while they kept exactly the same investment. The practice was called “bed and breakfasting”. HMRC stopped it by introducing share matching rules. If you buy the same shares within 30 days after a sale, the sale is matched with that purchase, so the sale and purchase cancel each other out.
The rule is now part of the standard share identification system. It applies in a set order, which you cannot change.
| Order | Rule | What is matched | Cost used |
|---|---|---|---|
| 1 | Same-day rule | Shares bought on the day of the sale | Cost of those shares |
| 2 | 30-day rule | Shares bought in the next 30 days | Cost of those shares |
| 3 | Section 104 pool | All other shares you hold | Average cost of the pool |

How the 30-day rule works in practice
The 30-day rule looks forward from the date of the sale. If you sell on day 0 and buy the same shares at any time from day 1 to day 30, the purchase is matched with the sale. The matched shares are removed from the sale, and the remainder, if any, comes from the pool.
Worked example
Selling and rebuying a gain
You hold 1,000 shares that cost £5,000. You sell all of them for £9,000, which would be a gain of £4,000. Two weeks later you buy 1,000 of the same shares for £8,800.
- Without the rebuy: the gain is £4,000.
- With the rebuy: the sale is matched with the new purchase, so the gain is £9,000 less £8,800 = £200.
- The original cost of £5,000 stays in the pool, where it is still available for later.
The gain has not disappeared. It is deferred, because your original cost of £5,000 is now the pooled cost of the shares you hold. You pay the tax when you finally sell shares that are not matched with a recent purchase.

The rule and losses
The rule stops you creating a loss through a quick rebuy. Suppose your shares cost £9,000, and you sell them for £6,000, a loss of £3,000. If you buy them back for £6,100 within 30 days, the sale is matched with the new purchase, and the result is a loss of only £100, not £3,000. The larger loss stays hidden in the cost of the new shares until you sell for real.

To keep a loss, wait at least 31 days before you buy back, or buy something similar but not identical. HMRC treats shares as the same if they are of the same class in the same company. Different companies or different funds are not identical, even if they track the same index, although you should be sure the investment is genuinely different.
Partial matches
If you rebuy only some of the shares, only that part is matched. Selling 1,000 shares for £9,000 and buying 400 back for £3,400 within 30 days matches 400 of the shares to the purchase. The other 600 come from the pool at the pool’s average cost. The total gain for the sale is £2,600. The calculator on this site splits the sale into the matched and pooled parts for you.
Same-day trades
A purchase on the same day as a sale is matched first, before the 30-day rule. Selling 400 shares for £3,600 and buying 400 for £3,500 on the same day gives a gain of £100, whatever the pool contains. This happens often when investors rebalance a portfolio within a single day.

Rebuying in an ISA or pension
A common way to use the allowance is to sell shares in a general account and buy them back in an ISA. This is often called “bed and ISA”. The 30-day rule only applies to purchases within your own taxable holding. A purchase inside an ISA is not matched with the sale, so your gain or loss is worked out in the normal way. You are limited by the ISA allowance, which is set each tax year. The same applies to a “bed and SIPP” transfer to a pension. Check the annual limits and any restrictions from your provider.
Rebuying through a spouse
Another way to deal with the rule is to sell shares and have your spouse or civil partner buy the same shares. HMRC’s matching rule only covers your own purchases, not your spouse’s, so the sale is not matched. This is known as “bed and spouse”. It needs a genuine arrangement. If you give money to your spouse to buy the shares and they hold them for themselves, the arrangement can work. If you keep control of the shares or the proceeds, HMRC may challenge it. Take advice for large amounts.
| Approach | Does the 30-day rule apply? | Limits |
|---|---|---|
| Rebuy in the same account | Yes | None, but the rule applies |
| Rebuy in an ISA | No | ISA allowance |
| Rebuy in a pension | No | Pension allowances and provider rules |
| Rebuy by a spouse | No | Must be a genuine gift |
| Rebuy a similar but different fund | No | Must be genuinely different |
| Wait 31 days or more | No | Market risk while out of the investment |

Crypto and the 30-day rule
Cryptoassets follow the same identification rules as shares. The same-day rule, the 30-day rule and the pool apply to each type of token. If you sell Bitcoin and buy Bitcoin within 30 days, the sale is matched with the purchase. Swaps between tokens count as a sale of one and a purchase of the other, so a swap and a swap back within 30 days is matched. See our guide to Capital Gains Tax on crypto.
Common mistakes with the 30-day rule
- Forgetting the rule looks forward. It covers purchases after the sale, not before.
- Assuming a rebuy creates a loss. The matched cost can remove the loss.
- Counting the 30 days wrongly. Day 1 is the day after the sale.
- Ignoring partial matches. Only the rebought part is matched.
- Buying “the same fund” in another wrapper without checking. An ISA is not matched, but an identical fund in a general account is.
- Not keeping dealing records. Matching needs exact dates.
What to do next
- List all purchases and sales for the holding over the last two months.
- Enter them in the Section 104 calculator.
- Check the matched cost and the gain.
- Read our guide to Capital Gains Tax on shares for the full picture.
Frequently asked questions
What is the bed and breakfast rule?
It is the 30-day rule. If you sell shares and buy the same shares back within 30 days, the sale is matched with the repurchase. Your gain is based on the price of the new shares, not your earlier cost.
How many days does the rule cover?
The 30 days after the sale. A purchase from day 1 to day 30 is matched. A purchase on day 31 or later is not.
Does the rule apply to purchases before the sale?
No. The 30-day rule only looks forward. Shares bought before the sale go into the pool, unless they were bought on the same day.
Does the 30-day rule apply to crypto?
Yes. The same-day and 30-day rules apply to cryptoassets, token by token.
Can I avoid the rule by buying back in an ISA?
Yes, in most cases. A purchase in an ISA is not matched with the sale. You are limited by your ISA allowance and your provider’s rules.
Does buying a similar fund count as the same shares?
Not if it is a different fund or company. Shares must be of the same class in the same company to be matched. Make sure the investment is genuinely different.
What happens to the gain I do not pay tax on?
It is deferred. The cost of your original shares stays in the pool, and the gain is taxed when you later sell shares that are not matched.
Does the same-day rule come before the 30-day rule?
Yes. The same-day rule is first, then the 30-day rule, then the Section 104 pool.
Can my spouse buy the shares back?
Their purchases are not matched with your sales. The transfer must be genuine, and you should not keep control of the shares. Take advice for large sums.
Do I need to do anything special on my tax return?
No. Report the gain using the matching rules. Keep the dates and prices of all your trades as evidence.
Official sources
- GOV.UK: Tax when you sell shares
- HMRC helpsheet HS284: Shares and Capital Gains Tax
- HMRC Capital Gains Manual: Share identification rules
Related guides and calculators
This page gives general information for UK taxpayers and is not tax advice. Capital Gains Tax rules can change and your own circumstances matter. Check the latest rules on GOV.UK or with a qualified tax adviser before you act.