Yes. Or the first buy losses offsets the second buys taxes. That's the way the accountant told me to do it, treat all buys as individual transactions (as they are) and sales take shares out of the earliest transaction until it's done then move on to the next oldest. If you do it that way the tax office has nothing to argue about you doing anything dodgy.