Brokerages internally seem to keep track of the cost of each share in a portfolio (one example is fidelity). When selling, other platforms, like QTrade, seem to only let you pick a number of shares to sell, and not which particular ones. So it doesn't give fine control over the amount of gain (or loss) generated by a trade.
Some spreadsheets I saw, to help keep track of capital gains and losses, will keep track of ACB for the stock as a single property-asset that grows or shrinks, rather than a series of unique assets each with their own cost tag.
Are the following two approaches (I don't know their technical name) both valid ways of keeping tabs on gains and losses, come tax season:
treat all units of the same stock symbol as a single "propery asset" and update the average cost of the whole thing before you sell. the average cost of the part you sell or dispose of is proportional to the fraction of the property you sell.
treat each unit as a distinct thing to sell. when you sell, choose which units you sell (in your books), and those that you keep. The ACB of the two parts evolve independently from there on.
- example spreadsheet https://www.dropbox.com/s/t2lm6zbn4uh569e/ACB.docx?dl=0
- calculation of superficial loss, CRA: https://www.cibc.com/content/dam/personal_banking/advice_centre/tax-savings/superficial-loss-partial-en.pdf
(I'm in Canada)