**Introduction**

As clients have unique demands and increasingly expect personalized financial advice, matching them with the right portfolio is not always easy. Join us on this walkthrough to uncover how Bambu’s ‘Health Check’ feature used alongside optimization models can help take this weight off your shoulders by simplifying this matching process.

Goal optimization is a feature on the Bambu platform that runs a ‘Health Check’ to determine if the end client can achieve their target goals through the suggested portfolios based on current financial commitments. Based on the ‘Health Check’ results, we use a range of optimization models to help us suggest the most appropriate portfolios to clients.

**Use Case:**

We are examining a goals-based investment platform that recommends users’ different portfolios every year to help them achieve their financial goals. Each portfolio has an expected return, sorted in an ascending order based on the return (i.e. Portfolio 1 has returns of 3%, Portfolio 2 has returns of 5%, etc.).

For end-clients, their journey begins with indicating the following: the amount of money they have now, how much they plan to invest each year, the portfolio they are keen on invest in for each year, the investment time horizon, and what their desired goal amount is at the end of this investment time horizon. With this information, the platform can then perform a projection to determine if the user can achieve their goal by the investment time horizon. Finding out the projected value of a portfolio is based on the following formula:

*The orange line shows the projected value per year and the purple line shows the desired goal amount. n* is the year number based on the client’s time horizon, *FVn* is the projected future value in the year *n*, *ci* is the investment amount in year* i*, *ri* is the portfolio returns in year *i*. Using this formula, there are three possible outcomes and recommendations illustrated below:

**Outcomes and Solutions**

**Outcome 1: ‘Just Nice’**

Under the ‘Just Nice’ scenario, the projected value meets the desired goal amount. The definition of “meets” is that the projected value is within 0-5% above the desired goal amount. In this scenario, no recommendation is needed. The graph below shows an example of a user being able to “meet” their goal.

**Outcome 2: ‘Surplus’**

A ‘Surplus’ means that the projected value of the chosen portfolio is greater than the desired goal amount. In this case, the recommendation should be to change the client’s chosen portfolio (i.e. choose a portfolio that reduces the portfolio’s returns, *ri*, so that the projected value falls within 0-5% of the desired goal amount). At the same time, the returns of the newly recommended portfolio in year *i+1* must be lower or equal to the portfolio returns recommended in year *i*. The reason for this constraint is because of a concept known as “de-risking” which states that as your time horizon decreases, the amount of risk you take should decrease as well.

To recommend the right portfolio, a Random Search Constraint Programming Algorithm is used. The investment amount per year, *ci,* is fixed and the decision variable is the portfolio returns per year, *ri,* where the domain *ri* is the set of possible portfolio returns available for investment. For example, if there are 3 possible portfolios to invest in (portfolio 1 – returns 3%, portfolio 2 – returns 5%, and portfolio 3 – returns 7%), then ri ∈ {3%, 5%, 7%}. The 2 constraints for the function are as follows:

1) The future value at time *n* must be within 0-5% above the client’s desired goal amount

2) The portfolio returns in year *i+1* must be lower or equal to the portfolio returns in year *i*.

After inputting the variables, the model recommends a portfolio each year that shifts the result from “Surplus” to “Just Nice”. The result shows that the new projected value (orange line), “meets” the desired goal amount (purple line) and the black line shows the recommended number of portfolios each year.

Comparing the original projections (blue line) with the recommended projections (orange line), we can see that we can arrive at the desired outcome by changing the combination of portfolios. The main reason why constraint satisfaction was used instead of constraint optimization is that the objective was to “meet” the desired goal amount, i.e. within 0-5% above the desired goal amount, instead of being as close as possible to the desired goal amount. If constraint optimization with an objective minimization function was used instead, it would have taken longer to find a suitable option due to the smaller set of solutions possible.

**Outcome 3: ‘Shortfall’**

Having a ‘Shortfall’ means that the projected value of the portfolio set is less than the desired goal amount. The recommendation should be to increase the client’s total investment amount ∑ 𝑐𝑖 𝑛 𝑖=0 so that the projected value would increase. The client can choose one of three options if there is a shortfall – the investment amount, *ci*, for each year remains constant, increases, or decreases. A linear programming model was used to solve this problem.

Option 1 – Constant Investment Amount per year

The portfolio returns per year, *ri,* is now fixed and the decision variable is the investment amount per year, *ci*. The objective of the function below is to close the gap between the projected value at year *n* and the desired goal amount:

The constraints are:

1) The projected value must be equal or greater than the desired goal amount

2) The investment amount each year must be the same

Brent’s algorithm was used to find a local minimum. The solution obtained shows that the projected value in year *n *(green line) meets the desired goal amount (purple line) and the recommended investment amount (red line), *ci* is the same for all years.

Option 2 – Increasing Investment Amount per year

This option is suitable for the younger users whose capacity to invest will increase over time as they accrue working experience and their income grows. To determine the investment amount for each year, *ci*, we change the 2nd constraint to fit this requirement, where:

The Sequential Least Squares Programming algorithm was used to solve this problem. The user is still able to achieve their desired goal through increasing the amount invested every year. This is illustrated through the diagrams below which shows that the projected value in year* n *(green line) meets the desired goal amount (purple line) and the recommended investment amount (red line) increases per year.

Option 3 – Decreasing Investment Amount per year

This option is suitable for older users who have less capacity to invest due to their many responsibilities and with retirement on the horizon. To determine the investment amount for each year, *ci*, we change the 2nd constraint to fit this requirement, where:

Once again, the Sequential Least Squares Programming algorithm was used. The solution illustrated below shows that the projected value in year n (green line) meets the desired goal amount (purple line) and the recommended investment amount (red line), *ci,* decreases per year.

**Conclusions: Visualising these solutions **

The image shows how the outcome of these algorithms can be transformed into a product feature, illustrating the above concepts in a simple and digestible visual for end-clients.

When the right optimization models are deployed appropriately, matching end-clients with the right portfolios becomes substantially easier. If you are interested in finding out more about Bambu’s ‘Health Check’ feature, you can access and read the documentation from our API Library website here. You can also test out the API directly through the website.

**Appendix: Explaining the Algorithms used**

**Random Search Algorithm**

Let f: ℝn → ℝ be the fitness or cost function which must be minimized. Let x ∈ ℝn designate a position or candidate solution in the search-space. The basic RS algorithm can then be described as:

1) Initialize x with a random position in the search-space.

2) Until a termination criterion is met (e.g. number of iterations performed, or adequate fit achieved), repeat the following:

a. Sample a new position y from the hypersphere of a given radius surrounding the current position x

i.There are a couple of techniques for sampling a hypersphere such as Marsaglia’s technique

b. If f(y) < f(x) then move to the new position by setting x = y

**Brent’s Algorithm **

Brent’s method is a root-finding algorithm which combines root bracketing, bisection, and inverse quadratic interpolation. The algorithm tries to use the potentially fast-converging secant method or inverse quadratic interpolation if possible, but it falls back to the more robust bisection method if necessary.

It uses a Lagrange interpolating polynomial of degree 2. This method will always converge as long as the values of the function are computable within a given region containing a root. Given three points x1, x2 and x3 Brent’s method fits x as a quadratic function of y, then uses the interpolation formula:

Subsequent root estimates are obtained by setting y=0, giving the following:

**Sequential Least Squares Programming**

Given a nonlinear programming problem of the form:

Where 𝜆 𝑎𝑛𝑑 𝜎 are Lagrange multipliers. *xk* can be defined as a basic sequential quadratic programming algorithm. An appropriate search direction *dk* can be defined as a solution to the quadratic programming subproblem. The formula is as follows: