How to decide the balance of the pie percentage?

@Dao Iā€™ll do a writeup on how to use it.

@pipo Yeah you just populate your list with tickers and make sure the corresponding number of stocks in line 50 matches.

It will work with others. LSE stocks would be AV.L, LLOY.L, BT-A.L etc

3 Likes

Does it also work for ETFs?

1 Like

Yeah you will just need to add the suffix .L

2 Likes

I have written a short guide on how to get started with using this: https://github.com/nickspacemonkey/efficient_frontier/wiki

Please ask if you need help or have any questions.

I should add that this program is by no means 100% correct. And is slightly subjective depending on the risk free rate being used, which in this case is just 0. Also my programming is by no means very advanced, Iā€™m just an intermediate dabbler, so my calculations and formulas used may be subject to error.

3 Likes

Is the portfolio with the highest return not the best one? I donā€™t care about volatility of my stocks, as long as the average likely return is higher.

Edit: Ok, reading up on the Efficient Frontier. It gives the highest level of return for a defined risk level.

I imagine that that is up to you. If the historic data includes the falls in value due to Covid19 then it may be missleading ā€œgrowthā€.

For example, if we look at airlines over the past 5 years, many of them will probably have low share price growth or even heavy losses due to the Covid19 crisis, however, if you look at the period prior to February 2020 they most probably have very good share price growths. eg. look at IAG.

I imagine the code is good to give you an idea or initial thought, but you should tweak the final weightings selected based on your views.

Yeah you are not wrong, Poor choice of words really on my part. The idea of this is that you want your portfolio to lie somewhere on the curve as that maximises return for level of risk taken.

The program will now display the portfolio with the maximum sharpe ratio and maximum return also.

Iā€™m bad at explaining lol.

2 Likes

No worries, itā€™s hard to explain stuff on text, maybe you could do a video of it!

I just read up a bit on Efficient Frontier and Modern Portfolio Theory after seeing this.

Is the portfolio with the maximum return not just 100% invested in whichever stock had the best return?

Yes you are correct. But the purpose of a portfolio is to limit risk. So you need to find a way of maximising return for the least amount of risk with a number of securities, and this is basically a method of doing that.

3 Likes

I got predictions of -15% on some of mine!

1 Like

Haha thatā€™s a winning pie then. But as they say past performance cant be relied on for future performance so hopefully you will be alright.

2 Likes

I have 3 pies. 'bluechip and long" est 15%.
ā€˜Bounce back and midtermā€™ est -7% and ā€˜tech, spec & EVā€™ estimates 40%. Honestly if i could average 8-12% annually on pies Iā€™d be more than happy with that. Still planning on buying outside of pies when theres opportunities to be found

Yes this is the first thing I thought of too when I saw the code. An exponential moving average might be better when calculating the mean.

Also when calculating the covariance, there are points in time where there are null values. e.g. in 2010 Facebook was not listed publicly. Are these ignored when calculating the covariance?

Good work though. Looks good. Have you considered hosting this as a web app?

Itā€™s not a huge deal that the date is set before the stock was listed. It will lower the statistical significance of the result as there is more data being used for some than others. But in the end we only want one figure, the average return of the stock. Depends how you want to get there, perhaps you are right an ema might be better.

Iā€™m really not that good at programming. Itā€™s just a hobby. Hence why it isnā€™t more user friendly. @Finki is the real boss around here. I hope to write some programs using his apis soon.

@pipo is handy enough with Python as well.

I use Python myself in work. It wouldnā€™t be a far stretch to get the code you have on your github hosting on @Finki 's API or even wrap it in Flask or Django and get it up on Heroku or some cloud server. Or even cloud host it on AWS with a simple web interface. It may end up costing a small monthly fee however which Im sure you donā€™t want.

Your analysis looks good though, thanks for sharing.

Hello everybody. After looking into @nickspacemonkeyā€™s project and reading up more on MPT I ended to looking to see if there is any online portofolio optimisation app. Mainly because I want to be able to see limits to the % in the portofolio (so not to have 15% in one stock even though it faired a lot better then others). And behold I have found one that fits the bill and more: https://www.portfoliovisualizer.com/

It is mostly free (at least that important feature) and it does make miracles. I was creating mostly with equal weights and some favoured stocks and after applying the optimisation it greatly improved my possible return.

3 Likes

Thanks for that :+1:helped me a lot as have a bigger pie

@adriantc

Same here. I have a pie with 30 dividend aristocrat stocks and it improved my return from 5.5 to almost 10%. It is now on par with VOO, but without the big tech names. Maybe @George you could implement such an optimization feature in the app at some timeā€¦ it would complement the pie very well.

I remember using this a while ago. Because it is only US stocks, I decided to make my own :stuck_out_tongue_winking_eye:

Trying to get this running on my Mac. Installed VS Code. Installed pip, installed numpy etc. Now when I run it within VS Code with Python 3 I get:

chantal@Gonzo effecient_frontier % /usr/bin/python3 /Users/chantal/Documents/GitHub/effecient_frontier/effecient_frontier.py
Traceback (most recent call last):
  File "/Users/chantal/Documents/GitHub/effecient_frontier/effecient_frontier.py", line 1, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Any help appreciated!