Portfolio Optimization in the Time of Covid-19

Author

Peter White

Category

Machine Learning

Date

May 25, 2020

Maybe it's not as exciting as the torrid love affairs in Love in the Time of Cholera, but taking some time during this pandemic to think about portfolio optimization could be just as fulfilling. Well, maybe not quite as fulfilling. But with love affairs illegal under lockdown, now is your opportunity to ensure that your asset allocation game is top notch.

If there is anything the last few months have taught us it's that we have no idea what could be coming next. 2020 has been a horror movie so far. At this point I don't think anyone would be surprised if we all end up in the upside-down by July. It’s a roller coaster for life and also for investing. We were (almost) all caught off guard by this coronacrash, and just about anything could be coming in its wake.

So how can you prepare for that which you can not predict? It sounds like an ancient riddle; a what is the sound of one hand clapping sort of deal. And in a way it is, because there's no perfect answer. You're never going to be completely ready for everything. All you can do is make your portfolio as robust as possible. It’s like raising a child: you can’t protect them for every issue they’re going to face in their lives. You can only teach them to be as resourceful and adaptable as possible and hope that they can deal with what comes at them.

One way to help your portfolio succeed against uncertain odds is to ensure that it is properly optimized. Of course, the definition of proper optimization is open to interpretation, but in our case we are looking for a robust portfolio that strikes a balance between risk and reward. While we want high returns, we also want to ensure that we aren’t caught with our pants down in the case of a catastrophic event like Covid-19. It's an often overlooked part of investing for a number of reasons, not least of which being that it's tricky to know which optimization method is best for your situation. A few posts ago we introduced you to our MCOS python library, which is a handy tool for helping sift through the weeds on optimization methods and find the right fit for your situation. Remember that portfolios are a lot like cats, you can't approach each one the same. Their behaviour is unpredictable, but MCOS helps you understand how your portfolios will react in the wild.

In that last blog we explained how MCOS works, this time let me show you some results in action. I've put together a portfolio full of a random* assortment securities with the aim of seeing how they would have held up through the crash so far. I've run the test on three different optimization methods including an optimizer based on Markowitz's theories, one using the nested clustered optimization method detailed here, and a very recent machine learning driven optimizer based on Hierarchical Risk Parity, which we will highlight in a video to be shown here soon.

MCOS Analysis


I ran the MCOS library to find the expected outcome, expected variance, and expected Sharpe ratios for our three optimizers in the hopes of understanding how they would react when tested against the Covid-19 crash (so far). Our goal is that by testing our optimizations against a number of hypothetical results we can infer how our portfolio will hold up in the face of the unforeseen. The optimizations were calculated on available price history from 1970-2017, and then the backtest was run from 2017 until May 4, 2020.

The optimal allocations we calculated using each of these optimization algorithms are as follows:

For reference, I’ve included the code I used to generate the following results:

num_sims = 50
op = [optimizer.HRPOptimizer(), optimizer.MarkowitzOptimizer(),optimizer.NCOOptimizer()]
ee = ExpectedOutcomeErrorEstimator()
cov_trans = DeNoiserCovarianceTransformer()
mu = mean_historical_return(prices_df()).values
cov = sample_cov(prices_df()*).values
obs_sim = MuCovObservationSimulator(mu, cov, num_sims)
results = mcos.simulate_optimizations(obs_sim, num_sims, op, ee, [cov_trans])

*Prices_df is a dataframe that includes date and Close price. Price history information obtained from Kaggle.com.

The results are as follows:

Expected Returns

Based on our initial conditions, we would expect that our particular portfolio would perform best out of sample when optimized using the Markowitz method. We can clearly see that HRP is probably not the right choice for our current situation, so we should avoid that.

Expected Variance

There is no clear cut winner when it comes to expected variance, but there is a clear loser. NCO is expected to perform marginally better than Markowitz, but both are miles ahead of HRP.

Expected Sharpe Ratio

If you've paid attention to the first two charts and know how to calculate Sharpe ratios you won't be surprised by this one: Markowitz is the clear front runner when judged by expected Sharpe Ratio, with HRP still trailing far behind.

Backtesting Through Covid (so far)

Using the portfolio weighting discovered above, we then backtested these portfolios from 2017 through May 4, 2020. From these results we would expect that our portfolio would perform best when optimized using the Markowitz strategy. We would expect the best returns and the lowest variance, while we would expect a much lower Sharpe Ratio from HRP optimization. And we can see from this backtest that is exactly what we see.

Portfolio 1: HRP
Portfolio 2: Markowitz
Portfolio 3: NCO

(backtest results provided by https://www.portfoliovisualizer.com/)

The Markowitz portfolio has both the highest returns and highest Sharpe Ratio for the period, while HRP lags far behind the group in both and has a much higher variance. The results will not always be this consistent, but for this random portfolio you can see that the MCOS generated expectations were bang on. This information is incredibly important for us, because while we may not have been able to predict the crash from Covid 19, we were able to use hypothetical results to determine which optimization method works best for us regardless of what comes our way.

Finding the proper optimization technique is not going to save you from everything. It doesn't make you Superman. That shouldn't be your goal, it's unrealistic. Instead your goal should be to be like Batman. He knows he doesn't have any super powers, so he does everything he can to be prepared for whatever comes his way, because he never knows what might come at him. Follow that lead and make MCOS one of the tools on your utility belt to help protect the safety of your portfolio.

* The randomizing algorithm I used was a sophisticated one in which I looked at a list of tickers and wrote some of them down.

 RSS Feed

Latest posts