The annual rate of return on an investment can be calculated as

And the top response to this question suggests that the return on a portfolio of such purchases is simply the weighted average of returns on individual transactions, where the weighting coefficient is the number of shares bought:
However, by this definition, it seems like the calculated portfolio return can be positive, despite losing money.
Consider the following example: I purchase two shares of stock, one for $100 and one for $10, and sell both for $50, the first held for 1 year and the second held for 0.5 years.

So I've spent $110 and received $100, but the calculated return is +1175% [ (-50% + 2400%)/2 ].
What am I doing wrong?
