Calculating the Optimal Portfolio in Excel | Portfolio Optimization
HTML-код
- Опубликовано: 30 июл 2024
- "Calculating the Optimal Portfolio in Excel | Portfolio Optimization" by Ryan O'Connell, CFA FRM. This video is based on the Modern Portfolio Theory (MPT) and the Efficient Frontier.
Chapters:
0:00 - Explanation of Assets
0:36 - Expected Return, Standard Deviation, and Weights
1:50 - Enable Data Analysis Toolpak and Solver Toolpak
2:25 - Get Historical Return Data from Yahoo Finance
3:31 - Create a Covariance Matrix
4:58 - Calculate Portfolio Standard Deviation
5:31 - Calculate Sharpe Ratio
6:39 - Find Optimal Portfolio Using Excel Solver
💾 Download Free Excel File:
► Grab the file from this video here: ryanoconnellfinance.com/produ...
👨💼 Freelance Financial Modeling Services:
► Custom financial modeling solutions tailored for your needs: ryanoconnellfinance.com/freelance-finance-services/
🎓 Tutor With Me: 1-On-1 Video Call Sessions Available
► Join me for personalized finance tutoring tailored to your goals: ryanoconnellfinance.com/finance-tutoring/
*Disclosure: This is not financial advice and should not be taken as such. The information contained in this video is an opinion. Some of the information could be wrong. This channel is owned and operated by Portfolio Constructs LLC
ALTERNATIVE TITLES:
Portfolio Optimization Made Easy with Excel
Optimal Portfolio Management: Excel Techniques Revealed
Building Your Ultimate Investment Portfolio in Excel
Excel Your Investments: A Guide to Optimal Portfolio Creation
Smarter Investing: Master Portfolio Optimization in Excel
💾 Download Free Excel File:
► Grab the file from this video here: ryanoconnellfinance.com/product/optimal-portfolio-calculation-excel-template/
👨💼 Freelance Financial Modeling Services:
► Custom financial modeling solutions tailored for your needs: ryanoconnellfinance.com/freelance-finance-services/
This is very fun! Thank you, I hope you keep sharing more content.
I'm glad you enjoyed it Michael! I appreciate the feedback and have no plans of stopping haha
Hi Ryan. Finally, I was able to download the file. Thank you so much, for writing.
You're welcome!
Interesting subject. It helps a lot. Thanks
OMG! This is amazing. Thank you so much!
You're so welcome!
Thank you so much Ryan, much appreciated
My pleasure!
Very informative ! Thank you
My pleasure!
Thank you. Great job!
Thank you too John!
Great videos. Thanks!
Thanks for watching!
Thank you brother Ryan for this wonderful video . Please upload a video of Treynor ratio explaining its advantages
My pleasure! I have a video where I briefly discuss Treynor here from many years ago! I can make a newer version though in the future: ruclips.net/video/ojm-DotUb94/видео.html
Yes brother. I read it
@@RyanOConnellCFA Thank you brother
Welcome
@@aniruddhaganguly5699 My pleasure, and glad it helped!
wonderful lesson,thanks
You are welcome!
Very helpful
lifesaver! thanks :)
You're welcome!
Omg, jsut mind blowed that I didnt discover that earlier.
Glad you found it now!
Great video! You have made a small error in calculating the variance-covariance matrix. Instead of dividing through by N-1, you divided by N. Only managed to spot this while working through the theory :)
Very useful... Thanks
My pleasure!
Hi, Ryan, thanks a lot for your very detailed solution! The only thing, I'm a bit confused with the behavior of the Expected Return, in cell C12, as it has actually *decreased* from 6.5% prior to the optimization, down to 6.3% thereafter. Please, if you could take a look and clarify?..
Hi Ryan, Thank you for the videos. Is there any video about CCAR and DFAST stress testing?
Hello Esra, thank you! I don't have any videos on those topics yet but I can certainly look into them in the future
Thank you!🙏
My pleasure!
Ryan - thanks for the video. Very simple explanation so appreciated that. In terms of assigning an expected return to a stock, would it be useful to use an analyst price target (and subsequent return) as the expected return?
Also, do you have a parameter to determine max and min weights. It seems simple with a portfolio of 4 or 5 stocks but with say 16 I cannot really determine what a max or min should be?
appreciate your help. Thanks
Charlie, the consensus (or median) analyst expectation would probably be your best bet for expected return. As for min weights, its hard to say, I haven't done enough research on that topic
Hey, Ryan! Thanks for the interesting and well-explained video. Which gold (asset) did you use for this video and where is it being traded on?
It's my pleasure! I used the GLD ETF which tracks the price of gold. Basically, you are buying the rights to physical gold that is stored for you (typically an expense fee of 0.5% per year). It trades on the major stock exchanges like NYSE
Hi Ryan, great video. What is impact of covariance matrix and how to understand covariance matrix ?
Hi there! Thank you for your comment. The covariance matrix represents the relationship between different assets in a portfolio, capturing how they move relative to each other. Understanding it is crucial because it helps in assessing the combined risk of the portfolio and optimizing asset allocation for the best risk-reward trade-off.
NIce...
What if the constraint is a 15% standard deviation? Can you please advise? Thank you.
u should put the standard deviation formula in the video description
Hey, Ryan. Thank you for walking through the steps. Very clearly and well explained.
1) How can I set it to calculate optimal portfolio if going short is allowed too?
2) I can't find nor downloadable link neither link to your website where I can download file. Is there a chance that you post one of those in the description to video? Thanks.
Thank you Saidakbar!
1. I'm not entirely certain on how you would do that.
2. I re-posted the file with a Github link (in the description). Please try that and let me know if it works better for you
@@RyanOConnellCFA Thank you very much, it worked.
@@saidakbarkhasanov8370 You're welcome!
Ryan, what is the advantage of using Daily Data over Monthly Data?
Ryan, just surfing around and stumbled on you and this video. Very interesting. Thank you. I'll play with it some more. BTW, I see there is some bad data at the bottom of your Raw Data tab on Row 253. Is this causing some wild error in the calculations? Just curious. Hey, I'm just down the road in Arlington.
Hey Tommy, great to hear from someone so close by! What do you mean by bad data in row 253? All the data looks fine to me. The returns (which our analysis is based on) stop in row 252
@@RyanOConnellCFA Hmmm, watching your video again, I don't see it. I think when I grabbed the data (using your template) for some other tickers, it had one extra row (Row 253) and that's where the extra line of "bad data" was. Disregard.
@@tommypain No problem Tommy! Also, I just released a more updated portfolio optimization video in excel here if you are interested: ruclips.net/video/XQS17YrZvEs/видео.html
@@RyanOConnellCFA Thanks, Ryan. I'll check it out.
Thanks for this. Really stupid question here but what hotkeys allow you to copy cells? I'm an excel luddite so I am just click and dragging the bottom right.
We all start that way Jake!
Ctrl + C allows you to copy
Then go to the last column that has values, you hit Ctrl + down arrow to go to the bottom row with values
Then you can go to the empty column where want to paste the values and hold Ctrl + Shift + up arrow. This will highlight the whole range. Then Ctrl + V to paste over the whole range
I like this youtube, can you tell be why you inserted the number 252 at the end of the standard deviation formula? Thank you
252 is the default number of trading days in the year after removing weekends and holidays when the market isnt open. This number is used to annualize returns and standard deviations
Nice video the real question is how to find the stocks that maximize the sharp ratio if only solver can do that . or can it ?
Hello! I have a newer and more sophisticated video on Portfolio Optimization here: ruclips.net/video/XQS17YrZvEs/видео.html
Please let me know if that helps you answer your question. It also uses the solver as portfolio optimization is an iterative math problem
Hello, In my own data set when I try to use the covariance function, excel keeps blocking it because it says my input range contains non-numeric data. I don't see how that could be true because my data only consists of percentages after doing the steps you demonstrated in this video. Do you know what I could be doing wrong? Your videos are super helpful thank you!
In the column next to your returns, use the formula =isnumber() and inside that function reference the cell that has the return. Drag it all the way down for each stock. Find the cell(s) where it says FALSE and you'll have your non-numeric data. Thanks!
How do we take max weight and min weights?
Hi, could you do a video on optimal portfolio optimisation with value at risk constraint
I can look into this in the future!
How do you go about finding the St Dev (Risk) values?
Overall great video!
Thank you! Excel has an inbuilt standerd deviation formula. You just input the range of data into that formula
@@RyanOConnellCFA Ryan, beautiful video. Easier to follow and comprehend than professor instruction. I have a question regarding the standard deviations you can obtain from the covariance matrix. By going diagonally from the top left to bottom right of the covariance matrix and taking the square root of each output, you can calculate the standard deviation of that factor. For instance, if you take the square root of the output from SP500 and SP500 you’ll obtain the SP500 input’s standard deviation. How is this standard deviation different from say using the standard deviation function on the SP500 historical data used in the sheet?
@@tagtrenton8659 Hey there! Great question! The standard deviation you obtain by taking the square root of the diagonal elements in the covariance matrix is actually the same as the one calculated using the standard deviation function (STDEV or STDEV.P) on the historical data. In the covariance matrix, the diagonal elements represent the variance of each individual asset, and taking the square root of the variance gives you the standard deviation. Both methods should yield the same results, and any minor discrepancies could be due to rounding or calculation differences in Excel. So, you can use either approach to calculate the standard deviation for each asset in your portfolio.
@@RyanOConnellCFA Thank you for the fast reply! I was getting minor discrepancies like you said and could not figure out why. Finally, I’m at peace lol. Thanks again!
@@tagtrenton8659 Awesome, glad you could figure it out!
Ryan, very good video and explanation. I trying to download the file, but this message appear on the screen; You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. I don't know if you can formatted the file in other form. Thank you
Please try now William, I have added a Github link to the description
@@RyanOConnellCFA Btw, I was wondering if you could share a link that is only uploaded to Google Drive? The direct download doesn't work for me because since I don't have the Excel program downloaded on my computer (only Excel online), it just downloads it directly onto "Pages" (i'm a macbook user) and the formatting comes out wrong. Thanks!
How to arrive at 35% and 15%? Is there a reason behind this? Or we can choose the minimum and maximum weight for each constituent weight to our liking?
Yes. You can change them. It is the strategic decision.
How do you determine what the min and max weights are for each security? Also if I wanted to include risk-free assets like US treasuries into the portfolio, would this still work?
min weight is how much you want to be invested in a certain stock, the lower it is the better for optimization
Hi
I dont understand how you found the st dev and exp return for each asset, can you please explain
You can get more precise and scientific in this step by following my 5 minute video on this topic here: ruclips.net/video/56CgFMoaQVo/видео.html
Why do you only use historical data from the last year and not over a period of, say, 10 years?
You could definitely use 10 years worth of data and that would likely make your results more accurate and reflective of the true covariances
How exactly does the matrix multiplication work
This is my favorite walk through of how this formula works: www.wallstreetmojo.com/mmult-in-excel/
Could you post the st. dev formula cell? I am having trouble access it
Here is the formula exactly as it was in the video:
=SQRT(MMULT(MMULT(TRANSPOSE(G5:G8),J5:M8),G5:G8*252))
@@RyanOConnellCFA Thank you! I really appreciate your videos.
@@RyanOConnellCFA Why "*252"?
@@donahuco 252 represents the average number of trading days in a year
Why you didn’t use adjusted close?
In hindsight, adjusted close would have been better to use
isn't expected return of gold = zero?
This may be true if you consider real returns (accounting for inflation), but most returns are quoted on a nominal basis (not adjusted for inflation). A rule of thumb is that the return on gold should be similar to the inflation rate