I think you just need to work out the net capital gain or net capital losses... So if you purchased some at $1.25 and sold them at $4, then that is a capital gain, so work that out first and then subtract all the losses from the capital gain from all the other purchases that you sold at $4...
If the final net value is negative then you have incurred a capital loss for the financial year and this can be offset in future financial years