Understanding 'Risk Management & Trading Psychology'

Lesson -> The Portfolio Optimization

8.1 - The tale of 2 stocks

We've spent a lot of time and effort trying to understand the risk associated with a portfolio. We have reached a crucial stage in our discussion - it is time to discuss portfolio optimization. It would be a good idea to start this discussion by understanding what portfolio optimization is and why optimizing a portfolio makes sense.

Let me ask you one question before we move on: What do you think the overall portfolio's return is if it includes investments in Infosys or Biocon? Let's say that Infosys has a 22% return and Biocon is 15%.

Although it may sound like a typical MBA question, this is an important question that you need to know how to answer.

The portfolio is equally divided between two stocks. This means that we would invest 50% in Infosys, and 50% in Biocon. This would mean that the portfolio's expected return would be -

= Investment in Infosys Expected Return of Infosys + Investment in Biocon Expected Return of Biocon

Remember, we discussed "Expected Return on a Stock" in detail in the previous chapter. Let's get to the bottom of it.

50% * 22% + 50%* 15%

=11% + 7.5%


The portfolio should return 18.5% annually.

Now, what if we changed the weights? What if you invest 30% in Infosys, and 70% in Biocon. Or, let's say 70% in Infosys or 30% in Biocon.

Let's look at Case 1.

30% * 22% + 70%

= 6.6% + 10.5%


Case 2 -

70% * 22% + 30%

=15.4% + 4.5%


We can do this for many weight combinations, it's obvious. Here is the table with a few omissions.


As you can see, returns vary depending on how much weight is invested. If I had chosen to invest only 40% in Infy, and just 60% in Biocon I would have received a 17.8% return. If I had invested 60% in Infy, and 40% in Biocon, my return would have been 19.2%. This is an additional 2% return.

We can draw a very important conclusion: because investment weights change, returns also vary. Each return comes with a risk profile. Therefore, it is important to note that each return comes with a risk profile.

Imagine this: If you had a portfolio of stocks with 'n' numbers, would it not be amazing if you could look at past data to determine how much each stock should be invested so that your portfolio produces the highest possible returns?

Optimizing your portfolio is exactly how this works. You can adjust the weights or optimize your portfolio so that the stocks you choose are -

  • To get the best return, you must identify the right investment weights
  • To minimize risk, you determine the right investment weights

Does that sound confusing? Fear not, just read ahead!

8.2 - Caution! Jargons ahead

You should now be able to see why optimizing the portfolio is important. Don't let me waste any more time convincing you.

Let's optimize the portfolio that we have been using. At this point, however, I want to remind you of some important terms.

Portfolio with minimum variance - Let's say you have 10 stocks in your portfolio. You should be able to adjust the stock weights to get different results. Results refers to the risk and return characteristics. A unique portfolio is made up of unique weights. A portfolio with 10 stocks each, 10% in each stock, is an example of a uniquely weighted portfolio. Another unique portfolio is one where you have stock 1 at 30% and stock 7 at 7.8% for the 9 remaining stocks. There are many combinations possible, and each weight combination has its own risk and return characteristics.

This means that there should only be one combination of stock weights that is possible to minimize portfolio risk. Technically, the combination of stock weights should be so that the portfolio's variance is minimal. This portfolio is sometimes called the "Minimum Deviance Portfolio". This portfolio is the lowest level of risk that you can take. If you are an extremely risk-averse investor, you should aim for a minimum volatility portfolio.

Maximum return portfolio This portfolio is almost the opposite of a portfolio with minimum variance. A minimum variance portfolio should have a mix of weights to achieve maximum return. The risk associated with a portfolio that has a maximum return is higher will also be higher.

Multiple portfolios, fixed variance - This is not a technical term, but something you should be familiar with at this stage. Although it may seem confusing at the moment, I am certain that you will be able to understand this concept better as we move on to portfolio optimization.

At least two distinct portfolios can be created for a given level or risk of a portfolio. The highest return portfolio will have the highest return, while the lowest returns will be achieved for the same level of risk.

Let's say that the portfolio has a 15% risk/variance. This will result in a portfolio that can return 30% (highest return), and another portfolio that can return 12% (lowest return). Both portfolios have a 15% risk, but different returns.

There could be many other portfolios, each with a different return profile, between these two portfolios. For a given risk level, you could have multiple portfolio combinations. Within these combinations, you will find a portfolio that has the highest return and one with the lowest return.


This concept will be dealt in the next chapter.

For now, keep it in your thoughts.

8.3 - Portfolio optimization (steps)

Let's look at the portfolio we have. The stock names and weights are as below. This is an extension of the portfolio that we have been using over the past few chapters.

(image 3)

Remember that the weights were randomly assigned and not subject to any thought process. The portfolio was constructed with this combination of weights. It was estimated that the portfolio's annual variance would be 17.64% and the expected return would be 55.14%

Now, our objective is to optimize the portfolio in order to achieve the desired outcome. The 'Solver tool' is required to optimize an excel portfolio. The solver tool is located under the "Data ribbon".
(image 4

Many people may not be able to find the "solver" tool under the data ribbon. It's possible that you haven't added it to the excel add-ins. These are the steps to add solver

  1. Click on Files to open the excel sheet
  2. Choose from a variety of options
  3. Select Add-ins (last option)
  4. Click on "Solver Add-Ins"
  5. Click on "Go"
  6. Recheck "Solved Add-ins"
  7. Click OK to close
  8. If necessary, close the excel sheet and restart your system
  9. You should be able find the solver tool by looking under the data ribbon

Let's optimize the portfolio in order to achieve the "Minimum Deviance portfolio". These are some simple steps you can take to get there.

Step 1 - Organize your data. This is key to solving problems. It is important that your cells are linked and data organized. There should be no hardcoding. This is how an excel sheet's data looks at this stage.

(image 5

Two important components have been highlighted, which will be used to optimize. The weights for each stock are shown in the topmost part. This will change when the portfolio is optimized. The expected return calculation for the 2 and parts of the portfolio will change as we optimize it.

Step 2 Use the excel solver tool to optimize your weights. This will provide a brief overview of solver. Solver can be used to solve a problem called an 'objective. Solver defines an objective as a set of data points that are derived from a series of formulas. It is possible to reduce, maximize, or change the objective's values or to set a desired value. This can be done while altering certain variables. According to solver, variables are elements of formulas that were used in determining the objective. You can, for example, reduce the portfolio's variance by changing the stock weights. The variance is the objective, and the weights the variable.

If we tell excel to minimize the objective (variance), the solver will check the formulas and work around it so that the objective's value remains the minimum.

Take a look at the image below. I am invoking the solver and will shortly ask it to minimize the variance.
(image 6).

Click on the data ribbon, then click on solver. The solver tool will open as shown above. Here is where we need to define our objective. As I said, the objective is to reduce the portfolio's annual variance. We are striving to find the portfolio with the lowest variance.

See the image below.

image 7

The objective is set to "Annual portfolio variance" - the cell address is highlighted under the'set objectives' field. Below, you'll see a red arrow indicating that the cell containing annual portfolio variance is highlighted. The green arrow highlights that we are trying to minimize the objective.

After this is done, we can inform the solver that we need to reduce the objective by changing variables. The variable in this instance is the stock weights.

image 8

As you can see, I highlighted each stock's weights in the "By changing variables cells" field.

Another option is to search for "subjects to constraints" field. The solver will reduce the variance by changing the stock weights. At this stage it also asks us if there are constraints that it should keep in mind when solving the problem to minimize the variance.

At this point, I am unable to think of a constraint other than that the total weight for all stocks should not exceed 100%. This basically means that I have 100% capital deployed across all five stocks. This is the possibility that solver might suggest to me to invest in fewer stocks than I have specified. Solver is an Excel tool and does not recognize stock picking.

Click on "add" to add a constraint. The following window will open when you click on "add".

image 9

Now the solver is fully set up. This is the final screen before you press "Solve".

image 10

For your convenience, I have highlighted the stock weights. These are the pre-optimized weights we randomly assigned at beginning of discussion. After optimizing, these weights will be modified so that there is the least variance for this set of stocks. Now let's press "solve" to see what solver has for you.

Here's the deal:

image 11

Solver solved the problem of the portfolio with the minimum variance and calculated the weights for each stock.

It wants us, for example, to increase Cipla's weight from 7% to 29.58% and reduce Idea's weight to 5.22% from 16%. And so on. It also says us that 15.57% is the lowest possible variance for this portfolio at the very earliest. The expected return of the portfolio has dropped to 36.25%, from 55.14%.

The variance cannot be reduced below 15.57%, regardless of what you do. These 5 stocks are your best bets, so 15.57% is the lowest level of risk.

Let me leave it at that. The next chapter will focus on optimizing the portfolio for a few more scenarios, and working towards creating an "Efficient Frontier".

To Summarize

  1. The weights given to each stock determine the portfolio's return.
  2. A portfolio with minimal variance is one that is as risk-free or has the lowest variance possible for a given stock set.
  3. Maximum return portfolio refers to a portfolio that has the highest expected portfolio returns for a given stock set
  4. We can fix the portfolio variance to create at least two portfolios with the highest or lowest expected portfolio returns.
  5. The solver tool allows one to optimize a portfolio using 'n' stocks on Excel.
  6. It is important to organize your data when using solver. This can be achieved by linking all relevant cells and avoiding hard-coding values.
  7. The portfolio can be optimized by putting the variable under constraint