Markowitz Portfolio Solver from Scratch and Stock Market Analysis | Python # 17

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

КОМЕНТАРІ • 248

  • @charlenestanton2237
    @charlenestanton2237 3 роки тому +52

    You have explained in less than 50 minutes what my lecturer struggled to explain in 3 months. Thank you!

  • @daveframi5715
    @daveframi5715 3 роки тому +56

    *The following content is created under an intellectual property license* Never have I ever seen such perfect and clear explanations.

  • @joelmarshall4989
    @joelmarshall4989 3 роки тому +44

    I love the math flow starting at 06:40 
Thanks a lot Ahmad !

  • @aishahoura2619
    @aishahoura2619 3 роки тому +33

    00:00​ Introduction
    00:47​ Markowitz Portfolio Optimization Problem (a recap)
    03:08​ Lagrangian Function
    05:38​ Optimal Weights
    11:11​ Lagrangian Multiplier Solutions
    21:35​ Our Portfolio Solver Equation
    22:17​ Python Implementation: SciPy approach (method 1)
    33:36​ Python Implementation: Our Solver (method 2)
    37:28​ Comparisons: SciPy Solver vs Our Solver
    41:00​ Summary
    41:40​ Outro

  • @karliefarrell6710
    @karliefarrell6710 3 роки тому +61

    Mesmerizing insights and its for free!!.. Good job Ahmad !

  • @louisrobertson3698
    @louisrobertson3698 3 роки тому +50

    This lecture will make your pocket rocket 🚀

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

      It sure did pocket made 5K USD yesterday thanks to this opt problem.

  • @frankfernandez6424
    @frankfernandez6424 3 роки тому +59

    Wow now I can use your equation to do my own solver. Thanks.

  • @leahprice1161
    @leahprice1161 3 роки тому +153

    This lecture slaps harder than my dads belt.

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

    This video sums up what took me about 4 years of gradual self learning to know in only 42 minutes!

  • @thomasyonsy3261
    @thomasyonsy3261 3 роки тому +7

    Suppose two portfolios A and B have an expected return of 10% each. But A’s risk is 8% while that of B is 12%. Looking at these two portfolios you would think, both give the same returns, but A has lower risk, I’ll buy A. But if you’re adventurous, you’d say portfolio A can return between 2% and 18%, while B can give between -2% and 22%. You might choose B. Portfolio B offers a chance of getting 22% return but there’s also the possibility that instead of making gains, you might end up losing money. The additional return is compensation for additional risk. Hence the notion, the higher the risk the higher the return. How do you make an optimal portfolio? By selecting the right combination of assets. If two assets are similar, then their prices will move in a similar pattern. Say, two Exchange Traded funds or ETFs from the same economic sector tend to show similar price movement, while, ETFs from different sectors show dissimilar price movements, as they lack correlation, making them a suitable set of eggs for your basket. Correlation is measured on a scale of -1 to +1. +1 indicates positive correlation where prices of two assets move par-for-par, while -1 shows negative correlation; prices move in opposite direction. If you put two assets with correlation of +1 in a portfolio, the risk they bring to portfolio will be the sum of the weighed risk of individual assets. However, if you put a pair of assets with correlation of less than 1, then the risk of the resulting portfolio will be less than the sum of the weighed risk of individual assets. By selecting different asset combinations you can achieve every risk to return combination in a portfolio. And this brings us to the efficient frontier, which is a graphical representation of different combinations of assets to achieve an optimal level of return at any given level of Risk. With risk on X-axis and return on Y-axis, this hyperbola shows all outcomes for various portfolio combinations of risky assets. This Straight Line is the Capital Allocation Line, which represents a portfolio of all risky assets and the risk-free asset, like government bonds. Tangency Portfolio is the point where the portfolio of risky assets meets the combination of risky and risk-free assets. And this portfolio maximizes return for a given level of risk. As you move towards the right along the lower part of the hyperbola you get lower returns at higher risk. Do the same along the upper part and you get higher returns at higher risk. The take away is that an asset's risk and return should not be assessed by itself, but by how it contributes to a portfolio's overall risk and return. We utilize Modern Portfolio Theory in our module 1, which has allowed us to achieve such returns…

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

    I have so much respect for how a good explainer you are. This video is amazing. Very clear, structured and most importanty calm (good comfort for ones who find these processes taunting already).

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

    I have never seen anybody teach so clearly

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

    This man is amazing.. very knowledgeable & good at explaining. Well done UA-cam for recommending me here.

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

    28:45 Thanks for showing me how to use scipy minimize function. Always had troubles with it.

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

    Brilliantly articulated multiple concepts within limited time, Thank you.

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

    Your explanation makes it much easier to understand. Thanks.

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

    A brilliant explanation of MPT. Wish I had come across this sooner. Thank you !

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

    I think one needs to be a genius in order to be able to explain such an incredibly complex thing in such a beautifully simple way.

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

    I swear I’ve learnt more during this quarantine than all the years I was in school 🙌🏽 I’m a new person now lol

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

      Wow that is awesome. Keep up the UA-cam learning Emily. UA-cam is a very rich source where you could learn almost anything.

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

    Amazing video needs to be shown in universities thank you for the development of this video.

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

    MPT which is Modern Portfolio Theory considers how an investor should choose a portfolio with a good trade-off between risk and expected return. Markowitz showed that the set of possible expected returns and risks.

  • @gurhan_aydn-edits8661
    @gurhan_aydn-edits8661 3 роки тому +1

    Thanks alot sir I really do appreciate your help with this video, I started off in this market not seeing the results I expected

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

    Portfolio management can be painful because it's all about making decisions about investment mix and policy, matching investments to objectives, asset allocation for individuals and institutions, minimising risk while keeping good returns and balancing risk against performance and not everyone could handle this successfully. Ahmad did an excellent job in clarifying all concepts jointly.

  • @БеняКузин
    @БеняКузин 3 роки тому

    Oh my GOSHHH. I am going to watch this so many times

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

    In finance, the Markowitz model - put forward by Harry Markowitz in 1952 - is a portfolio optimization model; it assists in the selection of the most efficient portfolio by analyzing various possible portfolios of the given securities. Here, by choosing securities that do not 'move' exactly together, the HM model shows investors how to reduce their risk. The HM model is also called mean-variance model due to the fact that it is based on expected returns (mean) and the standard deviation (variance) of the various portfolios. It is foundational to Modern portfolio theory.

  • @thejoker9418
    @thejoker9418 3 роки тому +2

    Thank you very much Ahmad !

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

    Best lecture on planet earth

  • @ДенисКожин-е5ш
    @ДенисКожин-е5ш 3 роки тому +1

    Clear lecture. Disclaimer: No student debt was created during the watching of this video.

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

    Learnt more in this four lecture than in the 4 months in class ✌🏻

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

    Underrated GURU !

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

    you explained it as simple as possible.. thanks

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

    I wish my Professors approach their lectures like this.

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

    2:04 relative price changes are ratio of current period vs previous one ?

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

    This was extremely helpful and needed. Thank you so much.

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

    29:52 Sir, is the bounds necessary because it not part of the optimization problem.

  • @elisabethgraham866
    @elisabethgraham866 3 роки тому +217

    Funny. I understood most by a guy that does not look like people from Goldman Sachs

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

    AMAZING AHMAD !

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

    Definitely will add this to my playlist for later! 🤙

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

    2:33 How is minimum accepted return an input to the problem ?

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

    Great lecture, well done! I do have a question, for the Lagrangian function, with only a handful stocks, it suggests negative weights. Is there a way to set a constraint for long only approach? Appreciated much.

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

      Hi! I have also faced the same problem. Were you able to fix it?

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

    Интересная информация, благодарю за нее

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

    great teacher really helped, thanks

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

    This video is very clear!

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

    29:21 Wow, never knew we could model the cost function as a python function

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

    Интересно, спасибо за видео)

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

    Your content is freaking awesome

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

      I am happy that you find it awesome

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

    The Efficient Frontier takes a portfolio of investments and optimizes the expected return in regards to the risk. That is to find the optimal return for a risk.

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

    You are a genius. Thank you sir.

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

    Love the part about making money from mathematical Convex Optimization.

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

    Very nicely explained. Great !!!!

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

    Wow! It should have been atleast 3 hours. Tuned me in like a netflix show.

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

    Gem of a lecture thank you

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

      Glad you think so, Gretta ! I'm very happy for you

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

    Brilliant explanation

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

    An excellent video with useful information.

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

    incredible! thank you

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

    Superb.. thnk you Sir :)

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

    Informative tutorial.

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

    Great lecture from UCLA USA

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

      Thanks and welcome. Pleasure it is !

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

    2:54 How come 1^T w = 1 is the same as sum of all wi ?

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

    A solver using 7 lines of python code at 37:22 got me going nuts ! How did you do that Ahmad !?

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

    thank you so much for this clear explanation

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

    Nice explanation, thanks for sharing

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

    15:01 How its scalar a, b and c ?

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

    I always thought of Markowitz efficient frontier as a parabola where the optimal values lie along the upper half of the parabola line. Anyways, the Efficient Frontier gives you a way to balance your portfolio.

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

    Thanks for the video.

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

    VERY GOOD explanation...

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

    Hi Ahmad. Just one question, if we get w = [0.2, 0.3, 0.4, 0.1], does that mean we have 20% in the first stock, 30% in the second, 40% in the third, and 10% in the final stock. It all sums up to 100% ? Thank you for awesome lecture.

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

    Great presentation skills.

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

    it was very helpful. Thanks a lot!

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

    The Markowitz Portfolio Theory is no other than a combination of assets, i.e. a portfolio, is referred to as "efficient" if it has the best possible expected level of return for its level of risk usually proxied by the standard deviation of the portfolio's return

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

    YEAH, QUARANTINE VIDSSSSSS 2021 !!

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

    Excellent professor!!!!!!!

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

    Thanks Ahmad !

  • @Faruk.00
    @Faruk.00 3 роки тому

    As investopedia points out, it assumes that asset returns follow a normal distribution, but in reality returns can be more the 3 standard deviations away. Also, the theory builds upon that investors are rational in their investment, which is by most considered a flawed assumption, as more factors play into the investments.

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

    I coded one myself, but for mutual funds. This would help if you extended this functionality for that cause.

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

      It could definitely be extended and applied to hedge fund analysis.

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

    The Markowitz solution can easily find highly leveraged portfolios (large long positions in a subset of investable assets financed by large short positions in another subset of assets)

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

    How to determine the optimal asset weights for a risky portfolio and how to allocate a portfolio between the optimal risky portfolio and the risk-free asset ?

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

      It is the w vector derived and implemented in the video.

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

    Please help with this problem I have homework An investor wants to put together a portfolio consisting of up to 5 stocks. Using the Markowitz method, what is the best combination of stocks to minimize risk for a given return? In this model, we calculate stock returns, the variance of each stock, and the covariances between stocks, using the Excel functions AVERAGE, VARP and COVAR.

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

    23:39 Can we use google API ?

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

    Now I think I’d like to see a video on Gold’s role in “Deleveraging”

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

    How do you work out the optimization problem using Langrange?

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

    Altyazılar için teşekkürler

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

    awesome quality useful content

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

    great! please upload more videos about portfolio theory

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

    Thanks a-lot sir I really do appreciate your help with this video

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

    @Mallie Bayes, yes increasing

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

    Well done boss. 💪🏻

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

    Portfolios that cluster to the right of the efficient frontier are also sub-optimal, because they have a higher level of risk for the defined rate of return

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

    A portfolio that gives maximum return for a given risk, or minimum risk for given return is an efficient portfolio. Thus, portfolios are selected as follows:(a) From the portfolios that have the same return, the investor will prefer the portfolio with lower risk, and (b) From the portfolios that have the same risk level, an investor will prefer the portfolio with higher rate of return.

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

    love your videos! keep it up:)

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

    Well done 👍🏻

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

    Is it possible to have zero weight in a particular stock in Markowitz portfolio optimization ? Zero weight implies that nobody wants it which will actually lead to decrease in price, however it is not feasible.

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

    Pretty awesome world we live in: I can learn all this for free.

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

    Nice handwriting I see it has improved compared to your last tutorials.

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

    Thanks a lot...it was really helpful :)

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

    Very clear, thank you so much :-)

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

    i have kwik question... at the pratfalyou is the 3 assets stand for the risk asset but how Kan we naw ? plz answerrrrrrrrr

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

    Is the CAGR true that CAGR = (end-price/start-price)^(1/years) - 1 ?

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

    What are the requisites to study CFA?

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

    fantastic video !