Back to Community
ChiPy FinSIG - Nov 2nd - Portfolio Optimization

Hi Chipy,

Here is a link to the presentation for tonight. Thanks again to RedShelf for providing the space and Quantopian for the pizza.

The first algorithm is the Single Factor Model with ordering done with the optimization engine. As the conversation turned to learning tools, a great way to learn is to clone and tweak other strategies. Quantopian forums are full of great stuff.

Clone Algorithm
58
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: 59fb5fd5e5960144e0a17b6d
There was a runtime error.
7 responses

Here is the notebook with the discussion on portfolio optimization. The blog post from which this was derived is here.

There is probably some capacity for someone with a little better math background to explain the finer points of convex optimization.

Loading notebook preview...
Notebook previews are currently unavailable.

And lastly, in case you are interested here is the original AlphaLens factor work for the EV/EBITDA factor. Watch out on this one, you can easily exceed the memory limit for notebooks.

Loading notebook preview...
Notebook previews are currently unavailable.

Awesome post with some great tools to learn about alpha and optimization.

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.

Hi,

The Markowitz Bullet does not build when I change the 4 stocks for 25 S&P 500 stocks and 4 ETFs, (see attached). I want to replicate one of my academic papers - 'Modelling risk reduction in equity portfolios using exchange-traded funds with multiple variance-covariance (VCV) matrices."

Have you tried a Shrinkage method on the VCV matrix? Ledoit and Wolf (2004) state that it improves the accuracy of the tangency portfolio and the GMVP when compared to the Markowitz (1952) matrix or the Single Index Model (Sharpe, 1963) matrix. My example will be looking at minimising portfolio risk by using the GMVP coupled with a weighting in the risk-free rate. This will allow us to be along the Capital Allocation Line.

Regards,
Frank

Please see these journals;
Ledoit, O. and Wolf, M. (2003) ‘Improved estimation of the covariance matrix of stock returns with an application to portfolio selection’, Journal of Empirical Finance 10 (5), 603-621.
Ledoit, O. and Wolf. M. (2004). ‘A-well conditioned estimator for large-dimensional covariance matrices’, Journal of Multivariate Analysis 88 (2), 365-411.
Ledoit, O. and Wolf. M. (2004) ‘Honey, I shrunk the sample covariance matrix’, Journal of Portfolio Management 30 (4), 110-119.
Markowitz, H. M. (1952) ‘Portfolio Selection’, Journal of Finance 7 (1), 77-91.
Markowitz, H. M. (1959) ‘Portfolio Selection: Efficient diversification of investment’, Edition 2.
Sharpe, W. F. (1963). “A Simplified Model for Portfolio Analysis,” Management Science 9 (2), 277-293.
Sharpe, W.F. (1964) Capital Asset Prices: A Theory of Market Equilibrium, Journal of Finance 19 (3), 425-442.

Loading notebook preview...
Notebook previews are currently unavailable.

I ran a risk breakdown of the algorithm using Quantopian's new risk model. Looks like it's a prime candidate for tighter risk controls, which are discussed in this lecture - https://www.quantopian.com/lectures/risk-constrained-portfolio-optimization

Loading notebook preview...
Notebook previews are currently unavailable.

Delaney wastes no time in showing of the new risk model. I love it. I like how the alpha calculated in zipline for the EV/EBITDA strategy shows up as spread between total and specific risk. I definitely agree about the risk controls. Spikes on serveral types of risk. The (high) bias towards value is expected given the factor used, but I was surprised at how consistently high (in absolute value) the volatility exposure was throughout. Additionally, the spikes in momentum risk are interesting, that is probably driven by the EV. I guess this is the content for my next Chipy talk - evaluating and constraining risk exposures.

Frank -
Sorry I meant to reply sooner. There are some NaN's in the covarience matrix when you add the additional assets. That causes the random portfolio generator to fail. You can fix that by dropping the offending asset or by setting the nan's in the matrix to a nominal value - of course that will hurt your ability to optimize, but it is an okay workaround. I'll share some code that does that. When I modified the covarience matrix, I still didn't get a great looking bullet, but that is because with 25 assets you now have many more possible portfolios. You could get a nicer looking scatter plot by ensuring the companies that have higher returns generally have higher weights - so not truly random weights.

Regarding the optimization, I have never worked with any other methods. The documents you share look interesting. I do think that there is some scope both in Q and for someone at Chipy (if anyone is reading this) to explore other methods of optimization. Certainly at higher speeds, the efficiency of the process would start to really matter. But for now, as a illustration of the process of optimization the cvx worked quick enough with enough accuracy to show the general process and value of optimization.

Awesome, we hope to have some new materials out shortly on how to detect risk exposure at the model level as well, as opposed to going all the way down to the portfolio level.