Back to Community
Applying Meucci’s Checklist to Portfolio Construction

This toy example algo incorporates some interesting Meucci techniques to improve portfolio optimization. Some of the key points are:

  • Use longer time series for estimation – have the law of large numbers work in your favour
  • Apply flexible probabilities to enhance estimation ie weight historical observations differently eg weight more recent data higher
  • Shrink your mean and covariance matrix to reduce estimation risk
  • Use a 2-step mean-variance optimization approach to choose the optimal portfolio on the efficient frontier according to your preference (satisfaction)

See also the post https://www.quantopian.com/posts/the-efficient-frontier-markowitz-portfolio-optimization-in-python-using-cvxopt for some background and some of the issues that arise in portfolio optimization.

Thanks

Peter

Clone Algorithm
33
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57714ec267770f0f89ae459f
There was a runtime error.
13 responses

Didn't Markowitz win a nobel prize for the stuff, but ended up doing equal weights stocks and bonds for his own portfolio? or something like that...

Here are the results using the same assets, but without any charlatanism (science) added to it, just equal weighted, monthly rebalancing.

Why add mumbo jumbo when you can do better by being "naiive"?

Clone Algorithm
18
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5771567c3e48240f8c190a5c
There was a runtime error.

Sorry, I kept too much cash in my other backtest, here is one with no cash...

Clone Algorithm
18
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57715d3e8b7a560f888638f3
There was a runtime error.

Or since our universe only contains stocks we know have done well in the past we could just assign weights randomly.

Clone Algorithm
6
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57715eac853caa0f8d2bde88
There was a runtime error.
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

James, so da*n funny...this entire industry is a joke.

Here is the same "algo" with 98% of cash invested at all times...now give me your 2/20 before I close my fund for new investors.

Clone Algorithm
18
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57719de3e0cfdc0f87f294db
There was a runtime error.

In closing, I am adding some leverage to the same "algo"...now turn over your entire life savings PLUS morrgage your house and invest it all in my black box fund, before I close it for new investors ;)

Clone Algorithm
18
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5771a3496164f30f8c9652af
There was a runtime error.

Hi James

To be clear, I did not cherry-pick these stocks. They are the exact same ones from the original post https://www.quantopian.com/posts/the-efficient-frontier-markowitz-portfolio-optimization-in-python-using-cvxopt. The authors of that post are: Dr. Thomas Starke, David Edwards, Dr. Thomas Wiecki...

My algo above doesn't actually start trading until 2007, I have corrected the code to make this clearer and will show the results in another reply later. Attached is YOUR random portfolio construction results (2007-2015) I got when I ran it.

Thanks

Peter

Clone Algorithm
2
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5771fe11d9bbc20f8c9c4768
There was a runtime error.

Hi Behavioral Trader

Well where do I start... First off there is no charlatanism, mumbo jumbo and the entire industry is not a joke. It would be a better community, willing to share more and help each other, if members did not jump to conclusions and make such remarks - such behaviour is not conducive.

My algo above doesn't actually start trading until 2007, I have corrected the code to make this clearer and will show the results in another reply later. Attached is YOUR equal weight portfolio construction results (2007-2015) I got when I ran it.

Thanks

Peter

Clone Algorithm
2
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5771f157513cdb0f8eacfe32
There was a runtime error.

To the rest of the Quantopian community who don't jump to conclusions...

Before I post the results of the toy example, let me clear the air:

  • the intention of this post was to show that it is possible to use Markowitz style portfolio optimization in Quantopian to build portfolios that suit your return/risk preferences. On the other thread, there were quite a few unanswered questions on how to do it
  • it was never about who has the best algo
  • it's not the only way to construct portfolios, like I said from the get-go it's a toy example, but I personally think it's worth having a look at and experimenting with. There are a lot of tweaks you can do to improve it...
  • of course, there's a lot more to know and you need to do your own homework!

Best of skill

Peter

One thing I want to highlight is that your estimates of the covariance matrix and the expected returns are key for better optimization results. The optimizer is very sensitive in particular to the expected return input.

I have just used some adjusted form of sample mean and sample covariance in the toy example, but this is where your skill in modelling should be applied...

The amendments I made to the original code are as follows:
- aligned the trading start date with the algo start date
- changed commission and slippage to the defaults
- changed rebalancing to time_rules.market_open(hours = 1, minutes = 30)

Conclusion: outperforms random and equal-weight construction techniques.

Also, note how the beta-to-SPY is low enough for the contest...

Thanks

Peter

Clone Algorithm
33
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 577217e711277c0fa01c83b2
There was a runtime error.

Yes this industry is full of charlatans who preselect securities for their backtests, play with backtest windows, but do not even check if their algo trades, or if it trades all the right securities half of the time. Some of them even shamelessly plug their websites and other spam.

LOL. The internet is full of trolls making unfounded accusations and misrepresenting the facts.

Replaced the stocks with the largest market cap stocks at the beginning of the backtest.

Equally weighted has Meucci beat.

Clone Algorithm
4
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57a33a056f21740ff5cd3bc9
There was a runtime error.