This post is about an Android application I wrote to calculate the Annual Equivalent Rate (AER) of a portfolio.

The AER of a portfolio is the annualised interest rate that, when applied to the portfolio contributions, results in the current value of the portfolio.

## Simple example

If I invested £100 exactly one year ago and the value now is £105, the AER would be 5%.

This is because £100 x (1 + 5%) = £105.

## Not so simple Example

However, things get significantly more complicated when there are multiple contributions on different dates.

What is the AER of a portfolio with contributions of £100 one year ago, £50 ten months ago that is worth £160 today?

It turns out to be approximately 7.04%. This is a typical example that is simply stated but has a not-so-obvious solution.

## The Algorithm

To compute the AER, I used a numerical method called the Newton**–**Raphson method.

The method starts with an initial guess to the root of a function. From here, we follow the derivative of the function in order to converge on the true root of the function.

In this case, the function we are interested in is:

Where is the ith contribution, is the ith day, is the current day and is the present value of the portfolio.

The derivative is:

The algorithm starts with an initial estimate and obtains a better approximation by using the relation:

This process is repeated until the difference between successive estimates is less than some threshold value or the number of iterations hits some predefined limit.

## AER Calculator

This led me to write the Android application AER Calculator, which can be found on the Google Play Store.

The (open source!) project can be found on GitHub.