Portfolio optimization

Shu Ming Peh
uptick-blog

--

Disclaimer: I am not vested in any of these stocks and I am not an equity analyst. Please do your due diligence or consult your financial advisor before investing!

TLDR: Given a list of stocks to choose, it is possible to optimize on higher returns and lower risk as compared to the average list of stocks. We can gain up to 5 absolute percentage points on returns or shave 7 absolute percentage points on risk, depending on your risk appetite.

This is a follow up of our first blog post (link) of narrowing stock picks using k-means clustering. However, after having a golden cluster or list of stocks, 57 to be precise, it does not seem really wise that we invest equal weightage to each stock. This prompted us to another problem statement: Is it possible to have some form of portfolio optimization that diversifies itself by selecting a number of low-risk and high return stocks? Such that:
1. Portfolio return is maximized or higher than average of golden cluster?
2. Portfolio risk/standard deviation is minimized or lower than average of golden cluster?

Summary
We turned to modern portfolio theory (MPT) given how it solves what we are interested; minimizing risk with a given level of return. If we choose to invest equally to each stock, in the golden cluster list, we can expect a portfolio annual return of ~24% and ~9% risk, with 2.6 sharpe ratio (sharpe ratio is a risk-reward measure; > 1 is considered good). Applying MPT, we are able to improve our portfolio expected return up to 29% with the same amount of risk or we can have a more balanced portfolio with 27.5% expected return and 2% risk.

Summary of how MPT fares with benchmark (equal weights to each stock)

What is MPT?
MPT
is a model that decides the allocation of a portfolio of stocks (or assets) such that it minimizes risk and achieve a target expected return. It tries to achieve a couple of things at once:

  • Diversification of stocks by varying allocation to high return and low risk stocks
  • Tries to maximize portfolio risk-reward measure

There are a few important (yet intuitive) assumptions of MPT:

  1. Risk is measured by the volatility (standard deviation or risk) of expected returns
  2. If there are two assets with equal expected levels of risk; always choose the asset with the higher expected return
  3. If there are two assets with equal expected rates of return, always choose the asset with lower risk. This (2 +3) creates a positive relationship between expected return and risk
  4. Allocation of portfolio is based only on expected return and risk

Dataset used
The data set is re-used from our first blog post, which pulls from Stocker and Yahoo-Finance python packages. And in fact we do not have to do any data pre-processing for this. Below is how the data set looks like.

yearly returns for each stock

Modeling approach
We can approach this problem as an optimization problem, as such we would like to (most importantly):

  1. Minimize portfolio standard deviation
  2. Subjected to a few constraints:
    - set level of expected returns
    - sum of allocation weights of all stocks = 1, ∑w(i) = 1
    - no short position, allocation weight of any stock, 0 ≤ w(i) ≤ 1
mathematical representation for those who are interested

Model results
It depends on your risk appetite of how you wish to structure your portfolio allocation. Regardless, any of the allocation below outperforms benchmark with higher expected returns and lower expected risk:

returns and risk based on different portfolio; each row places a different weight to each stock

Essentially, we are able to find out at each level of return what our portfolio risk would be. We will be able to plot it in a graph (below).

The dotted red line represents the risk of our benchmark (equal weights portfolio), and we should only consider returns before the dotted red line. As such, we should be looking at the boundary of 27.5% ≤ returns ≤ 29%.

For simplicity, we will only compare 2 portfolio allocation of 27.5% and 29% expected return. Apart from looking at their allocation, we check if the portfolio is really diversified with its correlation matrix.

Comparison of 2 portfolio allocations
Return 27.5%
Allocation

weightage of each stock at 27.5% expected return (and 2.2% expected risk)

Correlation matrix
Negative indicates that both stock moves in the opposite direction; if stock A goes up, stock B goes down. Positive will mean both stocks trend in the same direction; if stock A goes up, stock B goes up. Each element in the matrix indicate the correlation of returns between the two stocks. As such the diagonals of the matrix will always be 1 because the returns is comparing to its own stock. Just eyeballing the matrix, it seems balance to pass off as diversified.

correlation matrix of returns with each stock

Return 29%
Allocation
The final stocks picked are similar to above yet their allocation is vastly different. LII is given a lot more weight, because it tries to achieve an expected return of 29%.

weightage of each stock at 29% expected return (and 8.8% expected risk)

Correlation matrix
Same as above, it does seem balance enough to say this portfolio is diversified

correlation matrix of returns with each stock

Conclusion
I feel MPT has illustrated how it can be helpful in constructing portfolios, as well as providing us with a certain amount of expectation. It is also important to highlight the importance of having more historical data, so that volatility of returns and risk during financial crisis can be captured within our model. The next steps for us is to backtest our portfolio, and understand how much profit it will generate us from 2012 to 2018. More importantly, we will check in 6 months from now, and see how well our portfolios are doing, so stay tuned for that!

Some constraints of this analysis were that:

  1. We assume historical returns and variance to be good indication(s) moving forward
  2. The returns and variance chosen are static, and this will significantly affect the weights within the chosen portfolio

You may find my code and more detailed explanations of my model here: GitHub

Share this with friends who might find it useful! Also share with us your thoughts below, or give us a shoutout of what you would like us to solve for the next few posts!

Disclaimer: I am not vested in any of these stocks and I am not an equity analyst. Please do your due diligence or consult your financial advisor before investing!

--

--