Portfolio Optimization using Solver in Excel

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 97

  • @tejindersingh6645
    @tejindersingh6645 5 місяців тому

    I am indeed thankful to Prof. Fabian with such knowledgeable and hands-on session in such an easy manner. Thanks and keep the great work going on!

  • @f_x_eq_0
    @f_x_eq_0 3 роки тому +1

    Hi Fabian. Love this and really enjoying many of your tutorials. Thank you. Small top tip, trying to give back what little I can: Automatically name the columns by selecting the range (including the labels) > Control+Shift+F3 > Top Rows. ;-) Thanks again - great channel!

    • @FabianMoa
      @FabianMoa  3 роки тому +1

      Great tip! Will try it out

  • @aggarwalankur327
    @aggarwalankur327 4 роки тому +2

    While reading for Corporate Finance for my MBA, this video cleared many doubts of mine.
    Thank you so much for sharing this video!

    • @FabianMoa
      @FabianMoa  4 роки тому

      Glad it was helpful, Ankur!

  • @MaroonmeisteR
    @MaroonmeisteR 7 місяців тому +1

    Great and efficient explanation! Was looking for this.

  • @thegrandwaiwai
    @thegrandwaiwai 7 місяців тому +1

    Lifesaver! Ver clear - thanks Fabian!

  • @volhavakulchyk1324
    @volhavakulchyk1324 4 роки тому +4

    Thank you for making it perfectly clear! Not everybody is able to do that.

  • @saurabhtam
    @saurabhtam 3 роки тому +3

    I am a non finance guy and was trying to build a portfolio optimiser all by myself - this is easily the best video on this subject on YT for folks like me. What will change if I try to use daily returns instead of monthly returns?I am using data for the past 5 years to build a 20 stock portfolio.

    • @MrHailian1
      @MrHailian1 10 місяців тому

      I think everything will remain same except you need to use 252 instead of 12 to annualise the Return and Risk variables. Assuming 252 are the trading days in a year. Of course, Fabian can correct me here if it is not true what I said.

  • @percevalzinzin5983
    @percevalzinzin5983 4 роки тому +2

    Just brilliant! A huge thanks, some much knowledge transmitted in so little time :-) straight to the point! You show a good way of understanding how we can manage our portfolios efficiently.

    • @FabianMoa
      @FabianMoa  4 роки тому

      Thanks, Perceval. Glad you found it useful

  • @siktrading3117
    @siktrading3117 2 роки тому

    Excellent tutorial. Thank you very much!

  • @mohamedmadkour6926
    @mohamedmadkour6926 Рік тому

    Super like. Thats really great and clear. Would you mind also putting a vidoe on how hedge fund managers decides when to sell a position and replace it with another one using the same mechanism in this video ? Thanks

    • @MrHailian1
      @MrHailian1 10 місяців тому

      Great question, hope we can get answer of this.

  • @timilehinogunboyede5864
    @timilehinogunboyede5864 Рік тому

    Please, can you expatiate further on the continuously compounding formula bit? Do you have another video showing that in detail?

  • @VivekNaik
    @VivekNaik 4 роки тому +1

    Good
    You can also add CML to this along with charts for clarity EF

    • @FabianMoa
      @FabianMoa  4 роки тому

      Thanks for the input, Vivek. That would be for a Part 2 video

    • @VivekNaik
      @VivekNaik 4 роки тому

      @@FabianMoa great look forward for 2nd part

    • @Hcjfnzjc
      @Hcjfnzjc 3 роки тому

      @@FabianMoa has there been a part 2 for this? Would love to figure out how to align this data into potential scatter plots... like an alternative efficient frontier

  • @coversonkeys8617
    @coversonkeys8617 3 роки тому +1

    🙏 Thanks for the great tutorial 👍

  • @thodorakileras2963
    @thodorakileras2963 4 роки тому +1

    Thank you for this informative but also very simple to understand video. Would it be possible to make a video regarding GARCH model for analyzing and predicting the volatility?

  • @williamhayden2492
    @williamhayden2492 3 роки тому

    Hi Sir, I don't get it the rationale behind the formula @ 6:45 for the variance part. It is different from the normal 2 stock variance formula that we normally used?

    • @FabianMoa
      @FabianMoa  3 роки тому +1

      It's similar but the implementation in Excel is based on matrix algebra, which is more efficient.

    • @williamhayden2492
      @williamhayden2492 3 роки тому

      @@FabianMoa thanks for your reply sir. Actually I don't quite get the matrix part (my math not good), may I know where can I further study/research to get the rationale behind the matrix implementation part? What topic should I search? 🙏 Appreciate your guidance

  • @omarinlo
    @omarinlo 4 роки тому +1

    Going to apply it in TASI market.

  • @MrHailian1
    @MrHailian1 10 місяців тому

    Great Tutorial on portfolio optimisation. I am just wondering why you multiplied monthly return and monthly Std deviation with 12 to annualise them? Okay, there are 12 months in a year so it makes sense. However, in many other videos of other experts, they multiply with 252 when they have daily returns data, not with 360 because there are only 252 trading days in a year approximately. In monthly returns data case, multiplying with 12 means you are compounding returns over weekends and holidays as well. Should not it be any lower number, let's say 8 or 8.4, rather than 12 to account for non-trading period in a year? Sorry for this lengthy comment but it requires clarity. What is the consensus of academicians and practitioners on this matter? Thank you for producing high quality content on the UA-cam Fabian.

    • @FabianMoa
      @FabianMoa  10 місяців тому

      The mean and variance of returns are i.i.d., so the means and variances can be summed up respectively, which is seen as the effect of multiplication.
      So if a weekly return (that consists of 5 trading days) is 2% per week, we assume that based on i.i.d.:
      Week 1 return = 2%
      Week 2 return = 2%
      Week 3 return = 2%
      Week 4 return = 2%
      So a monthly mean return
      = 2% + 2% + 2% + 2%
      = 4 × 2%
      = 8%
      The same concept applies to variance.
      And standard deviation is multiplied by square root of time.

    • @MrHailian1
      @MrHailian1 10 місяців тому

      @@FabianMoa That's great explanation, Thank you. One further query regarding this tutorial. Using Indirect function to calculate var-cov matrix is efficient, that's wonderful. Could you please explain why you first locked the Row only and second time you locked the Column only within the formula of Covariance calculation using Indirect function? Why locking is important here and why row in the first instance and column the second time within the same formula?

  • @Slurfy73
    @Slurfy73 3 роки тому +1

    Hey cool excel …. I did this staff in the late 90 :)👍 do you know if there is an app we can use on Mac or iOS ?

  • @Therugbydetails
    @Therugbydetails 4 роки тому

    Great video, fair play

  • @leegengxiang2173
    @leegengxiang2173 4 роки тому +1

    Thank you, Fabian. Lets say I have the returns in daily format, how do I annualize the variance and std deviation? If the daily data is for example 252 days per trading year.

    • @FabianMoa
      @FabianMoa  4 роки тому +5

      For daily variance, multiply by 252. For daily standard deviation, multiply by square root of 252

  • @vivienl610
    @vivienl610 3 роки тому

    Very good, but i think it would be better if you could speaker slowly, considering some people are not good at excel, we want to follow the steps

  • @StockSpotlightPodcast
    @StockSpotlightPodcast 3 роки тому

    Great video. How would you integrate dividend yield + compound interest from that into this optimization problem in terms of total/expected returns?

  • @ibrahimhoballah625
    @ibrahimhoballah625 2 роки тому

    Great video

  • @mikeylejan8849
    @mikeylejan8849 3 роки тому

    I have 1,245 ETF files using Cummulative Abnormal Return and BEhavioral ETFS? I got all these ETFs from the New York Stock Exchange and I am using the New York Composite Index as my market index. I need to know the most optimal portfolio using 1245 ETF lists.

  • @jonathant1797
    @jonathant1797 3 роки тому

    Great video. Can you show you to calculate the month return using the daily price? I can't find the monthly return so I have to use daily price for it. Thanks!

    • @FabianMoa
      @FabianMoa  3 роки тому

      You can work with daily prices. Use it to calculate daily returns. To annualize the daily returns, multiply by 250 or 252 (based on number of trading days in the year). To annualize daily variance, multiply by square root of 250 or 252.

    • @jonathant1797
      @jonathant1797 3 роки тому +1

      @@FabianMoa I found the option to download the historical price by month. The data is sorted in asc order, so calc the return by (month / previous month) -1. And the numbers come out close, but not exactly like you have on your sample data. Is that because your data took dividend and stock split into consideration?

    • @UBPSUBPS
      @UBPSUBPS Рік тому

      @@jonathant1797 I might be wrong, but he took LN return. would appreciate if he could clarify it for us.

  • @sottso2844
    @sottso2844 2 роки тому

    Which way we import this data to excel?

  • @UBPSUBPS
    @UBPSUBPS Рік тому

    Sir, how did you derive the return data? as an example I checked AAPL 12/01/2018 Price of $39.44, 01/01/2019 price of $41.61. So LN monthly return would be 5.36% but on your data table shows 1.86%. what am I missing here?

  • @stephenhobbs948
    @stephenhobbs948 4 роки тому

    Great video. I have seen others about var-covar and solver. This one was very clear. I have daily returns that are negative (0.4, -0.2, for example) and you cannot have a negative log: =ln(.4/-2). What do you do in this case?

    • @FabianMoa
      @FabianMoa  4 роки тому +2

      Hi Stephen, the LN() is applied to the ratio of prices, not on returns. So if you have the daily returns, you can proceed to generate the covariance matrix

  • @jacopovivaldini8424
    @jacopovivaldini8424 4 роки тому

    Can you please explain the meaning of the Std Dev that you get for the portofolio? Why in order to have it you multiply the weights with the covariance matrix? I'm struggling to understand why is it still called std dev...
    Moreover, if you calculate the std dev of every single asset, you can't compare it with the portfolio's std. dev, because values are too different. Please let me know

    • @noobmother4058
      @noobmother4058 2 роки тому

      i’m 1 year late but it’s just the formula, portfolio risk formula. standard deviation just reflects risk levels

  • @mrmrabcabc123
    @mrmrabcabc123 3 роки тому

    Regarding to the Risk Free Rate, I have a 5-year data of asset classes and the US 5 year treasuary note annual data, do I just make an assumption as you said in the video or use the average 5-year annual rate or the annual rate for the 2020 calendar year? Thanks in advance, Fabian.

    • @FabianMoa
      @FabianMoa  3 роки тому +1

      The risk-free rate can be current risk-free rate (at the point of running the MVO)

  • @dennistheeditor
    @dennistheeditor 3 роки тому

    If I both long and short, how do I calculate portfolio optimization? Thanks!

    • @FabianMoa
      @FabianMoa  3 роки тому +1

      If you want to include short positions, then do not set a constraint in Solver.
      If you want to short a specific stock, you can set the constraint in Solver with e negative weight

    • @dennistheeditor
      @dennistheeditor 3 роки тому

      Thank you very much

  • @kierancook3397
    @kierancook3397 4 роки тому

    Hi could you show a quick example of how you calculated the returns using the continuously compounded formula? I've tried following your example for cell A2 (AAPL 1/01/2015) and I got ln(118.05/111.39) = 0.05807 = 5.8% and not 9.208% like you got. Thank you.

    • @kierancook3397
      @kierancook3397 4 роки тому +1

      I figured it out - it's the adjusted close price on Yahoo for anyone else wondering.

    • @JohnDoe-dh6zy
      @JohnDoe-dh6zy 2 роки тому

      @@kierancook3397 Good catch! I was wondering this myself but may have missed the obvious.

  • @lspriyatalluri
    @lspriyatalluri 3 роки тому

    Hi, How can we optamize for a big portfolio. Say Portfolio with more than 40 stocks

    • @FabianMoa
      @FabianMoa  3 роки тому

      Better to do in Python/R/VBA

    • @mrmrabcabc123
      @mrmrabcabc123 3 роки тому

      @@FabianMoa I have learned basic R from my current university program. Should I take a course including Python and Data Analysis?

  • @strayrue6276
    @strayrue6276 3 роки тому

    This is probably the best tutorial for portfolio optimization. Can I used this on a 10 stock portfolio? Thank you.

    • @FabianMoa
      @FabianMoa  3 роки тому +1

      Yes, you can

    • @chidieze5586
      @chidieze5586 2 роки тому

      As a rule of thumb in as much as the number of observations or the returns in this case is at least ten times the number of stocks. Though more computing power is required.

  • @jaimirock
    @jaimirock 3 роки тому

    why the covariance between the stocks with itself it´s not equal to 1?

    • @FabianMoa
      @FabianMoa  3 роки тому +1

      Covariance between stock A with itself is the variance of stock A.
      Correlation between stock A with itself is 1.

    • @jaimirock
      @jaimirock 3 роки тому

      @@FabianMoa you are right, I confuse the terms. Thanks for your fast answer, new suscriber!

  • @franciscocastillo8346
    @franciscocastillo8346 4 роки тому

    Hi! A quick question. What's the difference between the Markowitz portfolio optimization and risk parity portfolio optimization? Is it the same process in Excel?

    • @FabianMoa
      @FabianMoa  4 роки тому +1

      For risk parity, we ignore expected return. The fund manager will have a target standard deviation for the portfolio, and each asset class will contribute the same amount to total portfolio volatility.
      For example, if you take target a portfolio volatility of 20% and you have 5 asset classes, then the optimizer will select the asset class weights such that the contribution of each asset class to the overall portfolio volatility is 4%.
      For Markowitz, we look at the mean return and variance/std deviation.

    • @franciscocastillo8346
      @franciscocastillo8346 4 роки тому

      @@FabianMoa so risk parity considers just risk, while Markowitz considers risk and also reward? Said like that, Markowitz seems to be much better? Is that correct?

    • @FabianMoa
      @FabianMoa  4 роки тому

      " so risk parity considers just risk, while Markowitz considers risk and also reward?"
      Yes
      "Markowitz seems to be much better? Is that correct?"
      Not really. It depends on investors' objectives. Some wants to minimize risk, some want to maximize risk-adjusted return, etc. The models are chosen based on investor's objectives and concerns/preferences

  • @satyajeet709
    @satyajeet709 Рік тому

    Video is blurr, cant see excel calculation

    • @FabianMoa
      @FabianMoa  Рік тому

      You can increase the video resolution to 720p/1080p

  • @akinolaolatubosun4120
    @akinolaolatubosun4120 4 роки тому

    Pls i am unable to solve variance covariance through this method , pls i need your help

    • @FabianMoa
      @FabianMoa  4 роки тому

      Did you follow all the steps shown in the video?

    • @akinolaolatubosun4120
      @akinolaolatubosun4120 4 роки тому

      yes sir, i name my cell, APPLE, BA, NFLX, TSLA. Then entered equal sign>covariance>indirect>APPLE(f4).indirect>APPLE(F4))>Enter .
      Then my Average returns are:0.015626, 0.018168, 0.027699, 0.083233 respectively
      i use LN function to generate my return, the same data from Yahoo finance, 1/1/ 2015 to 1/12/2019(monthly) my return for TSLA is completely different to yours

    • @akinolaolatubosun4120
      @akinolaolatubosun4120 4 роки тому

      note: > means then, i like the method, the most simple method online. thanks

    • @FabianMoa
      @FabianMoa  4 роки тому

      Akinola, I'm sharing the source file to you for the 4 stocks. Can you check if the returns computed in my files are the same as the ones you have? Link: drive.google.com/open?id=1XXnchyeibkNFrBJSLop2lVanOVKZ-fvz
      A few things to check on your side is, are the prices sorted according to the dates in ascending order (i.e. oldest to newest). And I'm calculating based on Adjusted Closing Price.
      Let me know.

    • @mattrixx9019
      @mattrixx9019 4 роки тому

      @@akinolaolatubosun4120 did you use the ticker AAPL for Apple when you called the data? Also, did you use this as your reference in the spreadsheet? Instead of spelling out Apple, just use the ticker.

  • @nabarunghosal8607
    @nabarunghosal8607 3 роки тому +1

    Thankssssssssssss. Life saver

  • @BasJeBoi
    @BasJeBoi 4 роки тому

    You can't do *12 for the yearly returns right? You have to do =((L15+1)^52)-1, right?

    • @FabianMoa
      @FabianMoa  4 роки тому +1

      We can *12 if the returns are assumed to be i.i.d. (independent and identically distributed)
      And ^52 is for weekly returns, not monthly returns

    • @BasJeBoi
      @BasJeBoi 4 роки тому

      Yes I just read a paper written by Lo

    • @BasJeBoi
      @BasJeBoi 4 роки тому

      ​@@FabianMoa How about if you have a weekly dataset over 15 years.
      I compute the average returns for the data per year, but also for over the full set of 15 years per week.
      The yearly per year averages I can compute by doing *52 assuming IID.
      Can I do the same for the average over the full dataset? Or do i have to muliply that weekly everage by 52*15?
      Answer 1: FULL DATA SET AV R*52
      Answer 2: FULL DATA SET AV R*52*15
      Thanks!

    • @FabianMoa
      @FabianMoa  4 роки тому +1

      Answer 1 will do

    • @BasJeBoi
      @BasJeBoi 4 роки тому

      @@FabianMoa Thanks a lot! I thought the same!
      Have a nice day sir!

  • @syeedmohammeduzzalhossain5452

    Thanks

  • @satishnanda2996
    @satishnanda2996 3 роки тому

    Why does it recommend me to always put 100% of my portfolio in a single stock?

    • @FabianMoa
      @FabianMoa  3 роки тому

      Probably the return is much higher than the rest of the stocks, relative to the standard deviation

  • @aisyahsamsor6401
    @aisyahsamsor6401 4 роки тому +1

    is this markowitz?

    • @FabianMoa
      @FabianMoa  4 роки тому +1

      Yes, it's based on Markowitz's modern portfolio theory

  • @FRANKWHITE1996
    @FRANKWHITE1996 2 роки тому

    Subscribed

  • @joaovitorrodriguesalvesgon3189
    @joaovitorrodriguesalvesgon3189 4 роки тому +1

    Perfect!

  • @pargyropoulos
    @pargyropoulos 4 роки тому

    standard deviation is not a percentage

    • @pargyropoulos
      @pargyropoulos 4 роки тому

      wait... this is the standard deviation of a percentage.