# Calculate annualized return on stock with multiple transactions

I understand how to calculate the Annualized return on a stock when I have single purchase ie

``````(principal + gain/principal) ^ (365/days) - 1
``````

but how is it calculated when I have multiple buys and sells over a time period?

• Would I simply use the average cost per unit * current units – CodeKiwi Nov 1 '10 at 0:06

## 3 Answers

Treat each transaction as separate, with its own principal, its own gain, and its own number of days. Then the total annualized return is just a weighted average of each annualized return, with the weighting related to the number of shares in that transaction.

• Additionally, here is a related post I made which has some helpful links for performing calculations such as these. money.stackexchange.com/questions/2992/… – CrimsonX Nov 1 '10 at 17:43
• Excellent, makes perfect sense. Also this is the best method for me as this will be implemented in code rather than excel (I really should have meantioned this up front, sorry Eric). – CodeKiwi Nov 2 '10 at 21:24
• @CodeKiwi - In case you decide you need it, you can implement IRR in code as well, although it's a pretty inefficient algorithm since it's somewhat non-deterministic. Google will give you plenty of code samples. – Eric Petroelje Nov 3 '10 at 13:56

The best way to do this is to use IRR. It's a complicated calculation, but will take into account multiple in/out cash flows over time along with "idle periods" where your money may not have been doing anything. Excel can calculate it for you using the XIRR function

Since Brad answered with a great reply, I'd like to offer another comment: Be careful with the results. Annualized returns of short term trading can produce some crazy results. For example, a 10% gain in a week isn't unheard of for individual stocks, but (1.1)^52 = 142. or a 14,100% return. This may be obvious, but may help those who aren't so familiar with the numbers to understand that data running less than a year isn't going to provide as much useful conclusion as longer term. Note: Even a year doesn't really reflect success in a given strategy.

• Partial credit thanks joe, so do you think that for stocks held for less than a year I should add to the calculation as a weighted simple return rather than annualized? – CodeKiwi Nov 2 '10 at 21:26
• I think that when you include enough stocks, the risk of having the annualized return be a misleading number is very reduced. The weighted average approach or total portfolio calculation is a good idea. – JTP - Apologise to Monica Nov 2 '10 at 22:32