Boost your portfolio returns: A technical guide to portfolio optimization

Fri, Jun 18, 2021 5:26 AM on Stock Market, Recommended, Exclusive,

Article by Santosh Adhikari 

To cut a long story short: investor’s growing interest has created an enormous bubble in the stock market of Nepal. Unfortunately, this comes at the cost of new and naive investors. Maybe not only naive but bookish types of investors too are caught up in this bubble. This is exactly what I am witnessing after talking to my friend. What was interesting is when he was explaining how to make money quickly. As a professional Risk Analyst working at International Bank, I decided to test his knowledge of whether his claim is backed by any quantitative analysis. Much to my surprise, he was shelling money fueled by rumors, information gleaned in tea shops and social media. My friend is just an example; it made me think about how many people like him are caught up in this bubble. I realize how important to share what I know. It’s that I’m going to demonstrate how best to optimize the portfolio using a real dataset from six companies in six different industries of Nepal.

Well, what do I mean by portfolio optimization? Portfolio optimization is all about finding optimal portfolios. Let’s say, If you had just one day to tour Bangkok (having never visited there before) and you needed to create an itinerary for that day, how would you do it? Probably you would pick the four or five activities that are likely to be the most fun that comes at a reasonable price. But being unfamiliar with Bangkok, you pick an activity and not like it – that would be a waste of time and money. And that in a nutshell is portfolio optimization, as such, you want to create a basket of securities that maximizes your return while maintaining the amount of risk you’re willing to carry. Does the question arise about how to compile an optimal investment portfolio? Well, this means creating a balanced portfolio, which means spreading your investment capital across a variety of assets. This is something called the efficient frontier. The efficient frontier theory has remained shrouded in mystery until Harry Markowitz in 1952 mark the first significant breakthrough for the study on how risk-averse investors can construct portfolios to maximize expected return based on a given level of risk through his ground-breaking paper “Portfolio Selection”.

Note that all examples below are greatly simplified and reduce the mathematical heavy lifting. The stocks selected for this post is Mega Bank, Chilime Hydropower Company Limited, Asian Life Insurance Co. Limited, Everest Insurance Co. Ltd, Lumbini Bikas Bank Ltd., and Taragaon Regency Hotel Limited. Please note that companies chosen in the sample are selected randomly for demonstration purposes only. More details are given in the table below:




Mega Bank

Commercial Banking


Chilime Hydropower Company Limited



Asian Life Insurance Co. Limited

Life Insurance


Everest Insurance Co. Ltd

Non-life Insurance


Lumbini Bikas Bank Ltd.

Development Bank


Taragaon Regency Hotel Limited



For Portfolio Optimization, we need to follow the  three main steps :

Step 1: Calculation of expected return of portfolios

We are interested in close price only. The reason is that the close price is a true reflection of a stock’s value because it incorporates any corporate actions such as stock splits, dividends, and right offerings. The close price is retrieved from the Nepal Stock Exchange (NEPSE) from the period of 29/06/2020 to 27/05/2021 that we consider reliable. The dataset is analyzed using Python specialized libraries (Pandas, Numpy, and Matplotlib).

It looks like the Asian Life Insurance share price has been growing steadily since early July 2020. Whole 2020 has been a bad year but not so bad for Everest Life Insurance and Chilime Hydro Power when looking at the growth over the past six months. By plotting daily returns of actual prices, we can see the stock’s volatility. TRH has the highest positive spikes and a couple of negative ones. Smart investors can use volatility to make money whether a stock goes up or down.  


In the table below, the close price is marked by a blue color; daily return is marked by green color, and weighted return is marked by orange color.

Step 2: Calculation of Variance or standard deviation as a measure of the return variability (risk)

Standard deviation is calculated as the square root of variance by figuring out the variation between each data point relative to the mean. First, we need to calculate the correlation between two stocks. Correlation ranges from -1 to 1 where 1 is a perfect positive correlation, -1 is a perfect negative correlation, and 0 means there is no correlation between two stocks. For example, the 0.648 correlation between Mega Bank and Lumbini Bikash Bank tells us that their performance is related (Makes sense, they’re both banking sector). Second, we need to calculate variance-covariance. The covariance matrix is a table that contains two important pieces of information about an investor’s portfolio: 1) The risk level of each asset and 2) its interrelationship with another asset. Let’s use the following covariance matrix of a portfolio of six assets as an example. Diagonal cells give us the risk level of each asset. For instance, Mega Bank stock (0.084) is riskier than Chilime Hydro Power Stock (0.071). Other cells tell us how two assets are related.

Step 3: Construct the Efficient Frontier

Our portfolio consists of six assets of six different companies. What is the best weight combination in our portfolio? In order to find an optimal weight in a portfolio, we will iterate 5000 times to determine what the weights of the optimal assets might be. In each interaction, the loop considers different weights for assets and calculates the return and volatility of that particular portfolio. According to modern portfolio theory, pioneered by Harry Markowitz in 1952, there is an efficient frontier of portfolios, each with the highest expected return for a given level of risk. The tangency portfolio is known as the max Sharpe ratio or MSR portfolio. The global minimum volatility or GMV is the portfolio on the far left edge of the plot with the lowest volatility.


The efficient frontier is a graph with “returns” on the Y-axis and “volatility” on the X-axis. It shows us the maximum return we can get for a set level of volatility, or conversely, the volatility that we need to accept for a certain level of returns. On this graph, you can see the combination of weights that will give you all possible combinations:

  1. Minimum volatility (leftmost point)
  2. Maximum returns (topmost point)

   CHCL       MEGA    ALICL      EIC     LBBL      TRH

-------  ---------  -------  -------  -------  -------

24.2354  0.0103799  47.9906  6.62311  13.0246  8.11592



   CHCL     MEGA     ALICL     EIC     LBBL      TRH

-------  -------  --------  ------  -------  -------

2.96593  6.97023  0.499271  11.249  5.07422  73.2414


The red star denotes the most efficient portfolio with minimum volatility. We found the portfolio with minimum volatility, but you will notice that the return in this portfolio is pretty low. If you take another look at the daily return plot from earlier, we can see Taragaon Hotel is the least volatile stock, so allocating a large percentage to Taragaon Hotel for a minimum risk portfolio makes intuitive sense.  If we are willing to take a higher risk for a higher return, the green start that gives us the best return is the one with a maximum Sharpe ratio. In this scenario, a significant portion of the weight is allocated to ALICL and CHCL, which are quite volatile stocks from the previous plot of daily returns.

“The markets have been growing. I think it is a good time to sell”. “My stock is down by 10%. I would rather hold for some time”. “I want to buy X company stock, sell Y company stock, and hold Z company stock”. Nothing wrong with any of the above statements. End of the day, you want to make money. It makes a hell of a difference to your portfolio returns if you know how much weight to put in your equity portfolio.

Adhikari is a Risk Analyst, Alpha Analytics Operations, State Street Bank International GmbH. He can be contacted at