Mean Variance Optimization [Portfolio Construction]

What is Mean Variance Optimization?

Here is the definition from“Mean–Variance analysis is the process of weighting risk (variance) against expected return. By looking at the expected return and variance of an asset, investors attempt to make more efficient investment choices – seeking the lowest variance for a given expected return or seeking the highest return for a given variance level.”

It also assumes investors are rational and would choose the asset that had lower variance if the expected return of two assets were equal. I will assume you all are!

In layman terms, there are many techniques of portfolio construction, but this test shows two things. 

  1. Does adding a strategy increase the overall risk:reward of your portfolio or not?
  2. What are the appropriate weights each strategy in my portfolio should be assigned?

This is certainly a crude explanation of mean-variance optimization, but this isn’t an academic blog.

Testing Mean Variance Optimization

This test can be done with either historical or “predicted” returns. We will assign random weights to each of the strategies in the portfolio; the sum of all the weights shall equal 1 (or 100% of allocated capital). After assigning weights to each of the strategies we can generate a risk-adjusted return value or Sharpe Ratio. This is the Sharpe Ratio had we traded each of these strategies with the weight we just assigned to each.

After thousands of tests assigning random weights, we generate a plot of the thousands of Sharpe Ratios. We are trying to find the best weightings to lower the variance in our portfolio while keeping the return as high as possible.  The leftmost dots create the Efficient Frontier and the leftmost dot is considered the minimum variance portfolio. The graph’s legend or color bar shows the highest Sharpe Ratio possible. This portfolio contains the three “checked” strategies on the far left of the photo below and the highest Sharpe from this portfolio is 2.17.

We can then hover over the graph and view the weights that produced a specific Sharpe value or dot on the chart.  The idea here is we can see how to weight the strategies in our portfolio to give us the “optimal” or best risk-adjusted reward (optimal portfolio construction) – which is our ultimate goal as trading system developers.

The red dot shows equal weights or how our portfolio would have performed had we traded each strategy with the same position size.

Does this strategy improve my portfolio?

Now to answer the question “does adding this strategy to my portfolio help or hurt expected performance”?  In Build Alpha’s portfolio mode, you can simply include or remove strategies and quickly see if the Sharpe Ratio increases or decreases with this Mean Variance analysis. Below I have selected one additional strategy (see four checks on the far left of the photo below) and you can see a Sharpe Ratio improvement from our original 2.17 to 2.50.

Adding new individual strategies will almost certainly “smooth” out the portfolio’s equity curve, but does it actually increase risk: reward? This test gives a simple, quick way to quantify the addition (or subtraction) of a strategy.

Next Test

Here I have changed the ES (S&P500 strategy) in the portfolio. I unselected the top ES strategy and selected the other ES strategy. You can see the Sharpe Ratio worsening as it appears this portfolio only achieved 2.28 (vs. previous portfolio configuration of 2.50). This is a good strategy but just does not work as well with the other strategies in the portfolio as the original ES strategy we had included.

Mean Variance Optimization Summary

We want our money to be as efficient as possible and this test or techniques of portfolio construction gives us another check if it is or not.  No point in trading a strategy that is not expected to increase our overall risk reward.

It is now much simpler to compare strategies or to decide whether or not to include a strategy into a portfolio or not. Much of trading comes down to making informed decisions that maximize risk:reward and running this type of analysis certainly increases the information at your disposal. It is now only one click away in portfolio mode.


PS: Build Alpha allows traders to import systems built outside Build Alpha for analysis and portfolio construction. Now you can do all of this analysis on Build Alpha strategies, your own strategies, or any combination between.


David Bergstrom Author Photo Trading Edge

David Bergstrom – the guy behind Build Alpha. I have spent a decade-plus in the professional trading world working as a market maker and quantitative strategy developer at a high frequency trading firm with a Chicago Mercantile Exchange (CME) seat, consulting for Hedge Funds, Commodity Trading Advisors (CTAs), Family Offices and Registered Investment Advisors (RIAs). I am a self-taught programmer utilizing C++, C# and python with a statistics background specializing in data science, machine learning and trading strategy development. I have been featured on,,, Quantocracy,,, Benzinga, TradeStation, NinjaTrader and more. Most of my experience has led me to a series of repeatable processes to find, create, test and implement algorithmic trading ideas in a robust manner. Build Alpha is the culmination of this process from start to finish. Please reach out to me directly at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *