Asset Allocation using Convex Portfolio Optimization

Shreya Vontela
Where Quant Meets Data Science
9 min readNov 2, 2020
Source

In this blog post, we study and compare the asset allocation methodology followed through mean variance portfolio optimization(MVO) and Sharpe Ratio optimization.

Introduction

Modern portfolio theory(MPT) or mean variance portfolio optimization assumes that all investors are risk averse and hence would prefer a high return portfolio over a low return one for a given level of risk, in other words they would always chose a low risk portfolio over a high risk one for a given level of return.

Mean Variance Optimization

When we take a set of investable risky assets, each of the investor would prefer to build a portfolio such that their overall return is maximised, while minimizing the portfolio variance. This tradeoff between the risk and return for an investor depends on their personal risk profile (indicated by risk aversion factor).

By finding all such investable risky assets, and plotting them would give us the efficient frontier. In order to find the optimal portfolio for our investor on the efficient frontier, we need to write an objective function that maximizes the investor’s utility.

Step 1 : Framing the Risk and Return Objective

We need to frame the objective function of the mean variance optimization and set the appropriate constraints. Firstly let us assume that we have nassets and we invest w_i fraction of our money in each of these assets.

The asset allocation is given by the weights vector w

Portfolio expected return

This is the total return of the portfolio based on the allocated weights. Usually any investor’s ultimate goal is to maximize the portfolio returns but it is also important to sustain these returns over time. The sustenance of these returns depends on the portfolio variance.

Portfolio Variance

Any investor can benefit from diversifying his portfolio with assets that are not perfectly correlated. The portfolio variance reduces as the correlation among assets decreases. Having negatively correlated assets would be the ideal scenario but when we do not have such assets, investors usually long an asset and short another asset which is highly correlated with the first one. This acts as a hedge and reduces the overall portfolio variance.

Objective Function

The objective function to maximise the return and minimize the variance for an investor with risk aversion factor λ :

Risk Aversion Factor (Lambda : λ)

Investor riskiness is defined by the risk aversion factor (λ >0 ). It specifies the relative importance of the two terms : return and variance in the objective. The goal of MVO is to reduce the variance term of the objective function. A risk taking investor would have a low lambda, thus can afford to have a high variance portfolio. But a risk averse investor would have a high lambda and would prefer a low variance portfolio. In the extreme case when λ = 0 , the risk term is ignored and the return term completely dominates. In short, the risk aversion parameter represents a trade-off between the expected return and risk. We discuss about the optimal risk level going forward.

Step 2: Formulating the constraints

The objective is subject to some constraints :

  1. Budget constraint : The sum of all portfolio weights should be equal to one.

2. Short Selling constraint : If we consider that there is no short selling, all weights need to be positive.

3. Targeted return constraint : The expected return should reach at least the target value

There can be many other constraints with respect to liquidity, amount invested into specific asset classes, investment horizon etc. For the sake of simplicity, we consider only the above three constraints.

Step 3 : Solving the equations

  • There are several ways to solve the objective function. The most common one being the Lagrange multipliers method. In this blog I use a convex optimization library in python called pypfopt(PyPortfolioOpt) to get the optimal portfolio weights.
  • Alternatively we can use cvxpy(python library) or excel or we can also use bloomberg to do the entire portfolio optimization and construction process through PORT.

Portfolio Optimization using PyPortfolioOpt

Stock Selection :

We consider eight stocks for our analysis which span across five industries and have a dispersed range of correlations.

  1. Shopify Inc (SHOP) : Tech Industry Stock
  2. Amazon.com, Inc. (AMZN) : Tech Industry Stock
  3. NVIDIA Corporation (NVDA) : Semiconductor Industry Stock
  4. Netflix Inc (NFLX) : Media Industry Stock
  5. Charter Communications Inc (CHTR) : Media Industry Stock
  6. Regeneron Pharmaceuticals Inc (REGN) : Biotechnology Industry Stock
  7. Bank of America Corp (BAC) : Banking Industry Stock
  8. JPMorgan Chase & Co. (JPM) : Banking Industry Stock

Downloading Stock Prices :

Analysing the stock prices

Let us first define some helper functions to visualize the data using plotly .

Now we can visualise the stock prices over time.

Stock Returns

Analysis

Among all stocks, Shopify has the highest returns, NVIDIA has the second highest.

Regeneron seems to have the lowest returns , followed by Bank Of America which has second lowest returns.

Covariance Matrix

Analysis

Among all the stocks , Shopify and NVIDIA have high variance. Amazon and JPM have the lowest variance.

1. Mean Variance Optimization

Objective Function and constraints :

Analysis

  • In the Mean Variance Optimization, the risk aversion factor is considered to be 1 (risk taking investor).
  • Here we see that the weights are mostly allocated to Shopify which is has the highest return.
Mean variance portfolio performance with Lambda = 1
  • The Annual returns are very high and almost same as that of Shopify (82.37%). But the volatility is very high. So the investor is not gaining any diversification benefit.

2. Sharpe Ratio Optimization

Definition

Sharpe ratio is a metric used to estimate the performance of a equity portfolio with respect to the risk free rate of investment. Sharpe ratio is defined as the ratio of excess return of the portfolio to the portfolio volatility.

Optimizing risk aversion factor of MVO portfolio to get maximum sharpe portfolio

The MVO portfolio we discussed earlier was calibrated with a lambda of 1 and resulted in a sharpe ratio of 1.7. Now let us try to compute the optimal lambda or the optimal risk level of an investor, such that we can achieve the maximum sharpe objective.

To do this we run through a wide range of lambda values starting from 0.001 to 15 with an interval of 0.01 and try to find the optimal lambda for maximal sharpe ratio.

Here we see that, as lambda values increase, the sharpe ratio of the portfolio initially increases and then decreases after a point. Also, as expected, the volatility and returns reduce as investors become more and more risk averse.

Optimal Lambda

Optimal Lambda turns out to be 5.491. Now we re-calibrate the model with this lambda value.

Analysis

We see that the sharpe ratio has significantly improved due to the optimized lambda value. Now we do the same sharpe ratio optimization using the optimizer in pyfopt.

Sharpe Ratio optimization objective

Analysis:

Considering the risk free rate to be 0, we see that the sharpe ratio optimized portfolio gives the same result as the lambda optimized portfolio.

Although the return of sharpe ratio optimization is less, the volatility has significantly reduced. This suggests that the Sharpe ratio optimization gives a better result that mean variance optimization.

Now we can see how else we can improve the performance of this portfolio. One way is to allow short selling of stocks.

3. Portfolio optimization when short selling is allowed

Short Selling : Definition

Short selling is usually done when an investor estimates the stock price to depreciate. Here, the investor gains premiums on the stock by selling it without actually owning the stock. The investor then buys the stock on the delivery date to close the position. If the prediction is true, then we are gaining from the fall in the stock price. Also when the stock is sold on the current date , we get additional investable cash that we can use to invest in the bullish stocks.

So far in the above optimizations we have either invested in a stock or just stayed idle. Now as shorting is allowed , we can take leverage and invest more in the bullish stocks.

Analysis :

Here we see that stocks like Netflix and Bank Of America which had zero weights before are now shorted. This results in a significant increase in the sharpe ratio as well as the expected annual returns. This seems to be the best possible portfolio among all the choices.

Handling Constraints

As discussed before there could be innumerable additional constraints on the portfolio. One such constraint is discussed below.

Sector Constraint

Often asset managers are given limits on the investable weight for an asset so as to avoid high dependence of a portfolio on a single stock. Here we analyse the scenario where such constraints are given on the sectors.

Sample Constraints :

  1. We need to allocate at least 30% to tech industry and at least 20% to Banking industry
  2. We can allocate a maximum of 50% to tech and 30% to Banking industry

First we design a sector map and map it with our stock portfolio.

Set the constraints.

Optimize the sharpe ratio maximization portfolio after adding the constraints.

Analysis :

Due to the sector constraints, we reduce the weight allocated to Amazon. This does reduce the sharpe ratio but now we are not as vulnerable to tech stocks fluxuations as before.

Conclusion

In this post we compared the performance of various optimization methods like the traditional mean variance optimization, sharpe ratio optimization and also explored different ways to further enhance the model performance.

Based on the current analysis, we conclude that the sharpe ratio maximization portfolio with short selling allowed is the most optimal portfolio with sharpe ~2.0 and returns ~87%. The github code can be found here.

--

--

Shreya Vontela
Where Quant Meets Data Science

I am a data scientist who is passionate about quantitative finance. Always looking to connect and collaborate with fellow enthusiasts