# Exploring Markowitz Portfolio Optimization in the cryptocurrency space

### Introduction

A very popular portfolio optimization model is the Markowitz mean-variance optimization model. It is based on Modern Portfolio Theory (MPT), which was pioneered by Harry Markowitz in his paper “Portfolio Selection,” published in 1952 by the Journal of Finance. MPT is a mathematical framework for constructing the ideal portfolio that maximizes the expected return and simultaneously reduces the volatility(risk) of the portfolio.

“According to the theory, investment’s risk and return characteristics should not be viewed alone, but should be evaluated by how the investment affects the overall portfolio’s risk and return. MPT shows that an investor can construct a portfolio of multiple assets that will maximize returns for a given level of risk.” (Investopedia)

By applying Markowitz’s Portfolio Theory I intend to take advantage of the covariance of cryptocurrency assets to reduce the overall volatility of the portfolio. Indeed the findings, consistently with MPT, are that portfolio variance can be significantly lowered by exploiting low covariances between coins.

### Modern Portfolio Theory

The main inputs of this model are the historical returns of the selected assets. The model uses the average return of each asset as its expected return. Here, we use the standard deviation as a proxy to risk, the higher the standard deviation of an asset over a time period, the higher the risk associated. With these data, the model then computes the covariance between all the assets.

Calculating the covariance matrix will allow us to compute portfolio variance, which is then used to determine the expected level of risk for the entire portfolio.

The parameters of the model are the individual weights of each asset in the portfolio, expressed in percentage terms. However, the portfolio manager usually determines constraints to these parameters to limit the optimization results to viable portfolios. Usually, these constraints include no negative weights (i.e. no short positions) and a sum of weights equal to 100% (i.e. no leftover cash or leverage). However, additional constraints can be included depending on the objectives and limitations of the portfolio manager.

In the Markowitz mean-variance portfolio theory, one models the rate of returns on assets as random variables. The aim is then to choose the portfolio weighting factors optimally. In the context of the Markowitz theory an optimal set of weights is one in which the portfolio achieves an acceptable baseline expected rate of return with minimal volatility. Here the variance of the rate of return of an instrument is taken as a surrogate for its volatility. For a detailed explanation of the mathematical derivation of the previous formulas do consult the original 1952 paper by Markowitz, easily available online.

With all these in place, the simulation runs thousands of iterations of all possible portfolio weights to come up with the portfolios which minimize expected levels of risk for a series of return levels. The set of optimal portfolios form what is known as the ** efficient frontie**r. Within this frontier, the model can also find the portfolio with the maximum Sharpe Ratio — that is to say, the portfolio with the higher return per unit of risk.

### Methodology

By choosing the top 5 cryptocurrency with at least 2 years of existence on exchanges, we have our basket of assets, comprising of Bitcoin, Ether, Litecoin, Ripple and Dash. I downloaded the historical closing price data for each cryptocurrency, and then used them to compute the expected returns, standard deviation and correlation.

My first concern was the correlations of the assets. To have significant diversification benefits, the assets need to have low-positive or negative correlations. If we saw high correlations among the cryptocurrencies, this would’ve indicated that a Markowitz optimization model was not ideal for a crypto-only portfolio. However, this was not the case. In fact, most of the correlations were below 0.5, as seen in the following table:

These correlations are expressed as numbers between -1 and 1. Numbers close to 1 indicate that assets tend to move in the same direction, numbers close to 0 indicate that there is no relation between the assets, and numbers close to -1 indicate that assets tend to move in opposite direction.

The low correlation between assets was an indication that the Markowitz model might outperform the individual assets and/or an equally weighted portfolio from a risk-adjusted perspective. We will test out this hypothesis later with backtesting.

Using the characteristics of each individual asset and the covariance among them, it is possible to compute the expected return and risk of any possible portfolio. However, to limit the results to viable portfolios, I used the restrictions of nonnegative weights and the sum of total weights equal to 100%. Then, I generated 10,000 random portfolios and compute its return and risk profile. The portfolios with the maximum expected return for each level of risk generate what is known as the **Efficient Frontier**. Within the Efficient Frontier, there is a portfolio which has the maximum expected return per unit of risk. This is the **Maximum Sharpe Portfolio.**

### Implementation

I coded the simulation in python and this uses historical data to simulate the modeling of 10,000 portfolio by random generation of asset weights for each rebalancing month, and then finding the most efficient one.

Using a window of historical prices of 180 days, I chose an appropriate rebalance period of 30 days. This means that at the beginning of the algorithm execution and every subsequent 30 days, the model will use 180 days of historical returns to compute the efficient frontier. Finally, I programmed the model to order the weights of the portfolio with the maximum sharpe ratio every rebalance period

The return and risk of the 10,000 random portfolios is shown in the graph below. The Maximum Sharpe Portfolio marked with a blue dot.

The efficient frontier is the top edge of the bullet, which represents the optimal weights for maximizing expected return for each risk level (volatility). The dark green dots forming the top edge shows the optimized portfolio allocation for each level of risk.

These Maximum Sharpe Portfolio (blue dot) weights are displayed in the following graph. It shows the optimal weights that are calculated using the above mentioned Markowitz framework every rebalancing period (30days) with data from a 180 days lookback window, from 1 January 17 till 1 September 2017. According to the optimization model, more weights would be allocated to assets that show better expected returns per unit of volatility(variance), and this coincides with the asset’s future performance for that period.

Using these optimal portfolio weights, I performed a backtest of the strategy with Catalyst using all available YTD data (from Jan 1, 2017 to Sep 16, 2017). To compare if the markowitz model is an improvement over other common strategies, I ran a backtest for an equally weighted portfolio with the same assets, and additional backtests for a buy and hold strategy for each individual asset. Then, I computed the computed average annualized returns and standard deviations of each strategy. The results summary is displayed in the following table:

Here we can see that diversification is clearly as important in the crypto-world as in the real-world. Although individual buy-and-hold strategy has relatively high Sharpe ratio when compared to traditional assets, and may be considered good strategies, the optimized portfolio had even better performance. **It achieved a 453.33% annualized return with a standard deviation of 77.24%, which represents a Sharpe Ratio of 5.87. **This Sharpe Ratio is very high, and would be difficult to obtain investing in other major asset classes (equity, fixed income, etc.). Equally weighted portfolio is also better than ‘all eggs in one basket’ strategies, with Sharpe ratio of 5.22, but still underperforms when compared to a Markowitz optimized model. The success of the optimized model may be resulted from the inclusion of Ripple, which has very low correlation with other assets, but with high individual returns.

### Assumptions and limitations

However, this model of optimization comes with several caveats and limitations too. Firstly, we are assuming the normality of returns for Markowitz model to work well, which may not be true. Many research has been done on traditional assets that show non-Gaussian distribution of returns for traditional assets. This causes us to have an inaccurate estimation of risk/volatility by taking the variance as proxy. There is an asymmetry of standard deviation if a higher level of moments(3rd and 4th) is present in the distribution (skewness/kurtosis)

Secondly, our model here represents a zero-commission, transaction/tax free environment, which we know is not true in our present world. Therefore, if we were to set our rebalancing period to be shorter to dynamically adjust our optimal weights more frequently, this will result in a higher turnover rate, and thus higher trading expenses due to transaction costs. Returns in this experiment are calculated without fees due to simplicity, and thus real world returns will definitely be smaller.

Thirdly, as the saying goes, historical performance does not guarantee future results. In this model, expected returns are computed from historical data, and the assumption here is that past returns may likely to continue at the same rate. Although it may be a good indication of what can be expected, one must always ensure their investment strategy is as robust as possible by applying other methodologies when building a portfolio and doing adequate research to account for different scenarios.

### Future research

In this experiment, I am using a stochastic approach to show the many possible different portfolio combination that can be simulated, as shown in the markowitz bullet diagram. To achieve globally optimal weights, a more deterministic approach can be applied by using quadratic programming to solve the optimization problem as modeled below.

Another area of research for the future could be a mixed asset classes strategy. By exploring a portfolio of both traditional assets (securities, bonds) and cryptocurrencies, we can discover whether such a strategy can be superior to traditional/cryptocurrency only portfolio. This may be promising as the common notion is that the cryptocurrency market is uncoupled with traditional markets, which makes it suitable for Markowitz model approach.

Having reached the end, thank you for reading this to completion. I plan to write more on bleeding-edge investment strategies and asset management models. For a more detailed explanation on modern portfolio theory, you can look up the research paper by Harry Markowitz himself. The blockchain space is just starting to grow, and there is a huge potential ready to be capitalized.

“Bull markets are born on pessimism, grow on scepticism, mature on optimism and die of euphoria.” — John Templeton

*Inspiration taken from Rodrigo Gomez-Grassi “Markowitz portfolio optimization for cryptocurrencies in Catalyst” 2017*