Bought the same stock in multiple tranches? Calculate your weighted average, FIFO, or LIFO cost basis — and see your unrealised gain — in seconds. Includes a worked UK bed-and-breakfasting example.
Sale transaction
Sale proceeds
£11,700.00
Cost basis
£9,887.57
Gain / Loss
+£1,812.43
Avg cost / share
£164.79
Remaining position after sale: 80 shares at avg cost £164.79
For illustration only. This tool does not constitute financial or tax advice. Consult a qualified tax adviser for your specific situation.
Your cost basis is the original value of an asset for tax purposes — typically what you paid for it, including any transaction costs. When you sell, your capital gain or loss is calculated as sale proceeds minus cost basis. If you bought the same stock in multiple lots at different prices, you need a rule to decide which shares you're selling. That rule is your cost basis method.
The oldest shares are deemed sold first. Common default in many jurisdictions. Typically results in larger gains if the stock has risen over time.
Most recently purchased shares are sold first. Can reduce gains in rising markets but is not permitted in all jurisdictions (not available in the UK for individuals).
Total cost divided by total shares — a single blended cost per share. Used in the UK's Section 104 pool, which averages all historic purchases into a single running pool.
HMRC prevents investors from bed-and-breakfasting — selling shares to crystallise a loss and immediately re-buying them — using a strict share-matching order:
The calculator below shows a worked example where a sale followed by a re-buy within 30 days is matched under the 30-day rule — see how the gain calculation changes compared to the pool method.
Portledger's ledger engine applies HMRC Section 104, same-day, and 30-day matching rules automatically across every holding. No spreadsheet. No manual matching. Full audit trail for every cost basis figure.
See how Portledger works