MPT for more than two stocks?

Hi,



In section Section 3, unit 11 of the Quantitative Portfolio Management course, you provide a document that has the following conclusion:



Using the above concepts, you can extend your portfolio to multiple stocks. Construct multiple portfolios by simulating weights and plot the Efficient Frontier. You can do this by tweaking the Python code used for the portfolio with two stocks. Find the weights that give maximum value for the ratio, (Portfolio returns/Portfolio Standard deviation). These are the optimal weights according to Modern Portfolio Theory.



For example, with two stocks, the weights are "a" and "1-a". But what are the weights for more than two stocks? And once you have them, how can I iterate through all the combinations.



Moving from scalar math with only two stocks to matrix math with n>2 stocks is more than just a "tweak". Can you provide the code to show how this is done?



Thanks!

 

Hello Dr Gerald!



Please find the code on our GitHub gist here.

We continually improve our courses and your feedback is very valuable. We shall soon add this as a notebook in the course content!



Hope this helps!

Please reach out if you have any more queries.



Thanks!

Hi Gaurav,



Thank you very much for your response. It is quite helpful. I appreciate the support!



Best,



-Gerald