Given an investment portfolio and a ledger of withdrawls and deposits, I'd like to derive a performance metric that would allow me to compare its performance of a stock index.
A randomly generated example:
| Period | Balance | Cashflow |
|---|---|---|
| 0 | 5000.00 | |
| 1 | 5028.27 | |
| 2 | 5109.40 | 50 |
| 3 | 5065.93 | |
| 4 | 4773.27 | -250 |
| 5 | 4775.29 | |
| 6 | 7151.80 | 2400 |
| 7 | 7179.44 | |
| 8 | 7527.66 | 300 |
| 9 | 7488.77 | |
| 10 | 7519.12 |
That is, we had 5000 at start, 7488.77 at the end and in total of 2500 added to the portfolio.
The advice I've found so far is to calculate per-period returns (discounting for the cashflow), then compound them and look at the final number. More specifically:
Calculate per_period returns as (Balance[i] - Balance[i-1] - Cashflow[i]) / Balance[i]:
| Period | Balance | Cashflow | Ret_period |
|---|---|---|---|
| 0 | 5000.00 | ||
| 1 | 5028.27 | 0.57% | |
| 2 | 5109.40 | 50 | 0.62% |
| 3 | 5065.93 | -0.85% | |
| 4 | 4773.27 | -250 | -0.84% |
| 5 | 4775.29 | 0.04% | |
| 6 | 7151.80 | 2400 | -0.49% |
| 7 | 7179.44 | 0.39% | |
| 8 | 7527.66 | 300 | 0.67% |
| 9 | 7488.77 | -0.52% | |
| 10 | 7519.12 | 0.41% |
From that, calculate total return for the end of each period as (1 + Ret_period[0]) * (1 + Ret_period[1]) * ... * (1 + Ret_period[i]) - 1:
| Period | Balance | Cashflow | Ret_period | Ret_total |
|---|---|---|---|---|
| 0 | 5000.00 | |||
| 1 | 5028.27 | 0.57% | 0.57% | |
| 2 | 5109.40 | 50 | 0.62% | 1.19% |
| 3 | 5065.93 | -0.85% | 0.33% | |
| 4 | 4773.27 | -250 | -0.84% | -0.52% |
| 5 | 4775.29 | 0.04% | -0.48% | |
| 6 | 7151.80 | 2400 | -0.49% | -0.97% |
| 7 | 7179.44 | 0.39% | -0.58% | |
| 8 | 7527.66 | 300 | 0.67% | 0.09% |
| 9 | 7488.77 | -0.52% | -0.43% | |
| 10 | 7519.12 | 0.41% | -0.03% |
... to arrive at -0.03%.
The approach and the formulas make sense, but we arrive at the number that is negative. This makes little sense as we started at 5000, then added 2500 and arrived at 7519. That is, excluding deposits, we are still 19 in green.
Calculated differently, the rate of growth can be (7519 - 5000 - 2500) / 5000 = 0.38%, which makes a bit more sense.
I am clearly missing something, but what is it?
As I mentioned, investments are of the stock type, so the end goal is to have a metric directly comparable to the market indexes.