The 2026/27 annual exempt amount is £3,000. Taxable gain = max(0, gains − current-year losses − exemption). The allowance is not used to create a loss.
The model estimates other taxable income using the standard Personal Allowance, including its taper where applicable, then subtracts that income from the UK basic-rate upper limit. Gain allocation cannot exceed the taxable gain or fall below zero.
Sanity-check a £3,000 net gain with no losses gives zero tax. If taxable income has already used all basic-rate capacity, every taxable ordinary gain in this model is charged at 24%.