Efficient Frontier in Python p.1

Поделиться
HTML-код
  • Опубликовано: 30 июл 2024
  • Part 1: Building the Efficient Frontier in Python
    Code available at my website: quantpy.com.au/python-for-fin...
    In this series we are building the Efficient Frontier in Python with Dash as a web application over multiple tutorials.
    ★ ★ QuantPy GitHub ★ ★
    Collection of resources used on QuantPy RUclips channel. github.com/thequantpy
    ★ ★ Discord Community ★ ★
    Join a small niche community of like-minded quants on discord. / discord
    ★ ★ Support our Patreon Community ★ ★
    Get access to Jupyter Notebooks that can run in the browser without downloading python.
    / quantpy
    ★ ★ ThetaData API ★ ★
    ThetaData's API provides both realtime and historical options data for end-of-day, and intraday trades and quotes. Use coupon 'QPY1' to receive 20% off on your first month.
    www.thetadata.net/
    ★ ★ Online Quant Tutorials ★ ★
    WEBSITE: quantpy.com.au
    ★ ★ Contact Us ★ ★
    EMAIL: pythonforquants@gmail.com
    Disclaimer: All ideas, opinions, recommendations and/or forecasts, expressed or implied in this content, are for informational and educational purposes only and should not be construed as financial product advice or an inducement or instruction to invest, trade, and/or speculate in the markets. Any action or refraining from action; investments, trades, and/or speculations made in light of the ideas, opinions, and/or forecasts, expressed or implied in this content, are committed at your own risk an consequence, financial or otherwise. As an affiliate of ThetaData, QuantPy Pty Ltd is compensated for any purchases made through the link provided in this description.

Комментарии • 35

  • @Tapefruit
    @Tapefruit 3 года назад +6

    This series is awesome! Thank you! I just wish there was a follow-up discussing the parameters that were implemented but not used yet

  • @shagyhahn
    @shagyhahn 10 месяцев назад

    I really liked your step by step explanation. I will surely watch all your videos. Thanks for your time.

  • @John-dw6jb
    @John-dw6jb 3 года назад +1

    Great video, thanks!

  • @adribues
    @adribues Год назад +4

    Hi I get an error when I tried to print :"getData(stocks....) " , string indices must intgers typeerror. How I can fix it?
    Thank you!!!

    • @justgaming8867
      @justgaming8867 10 месяцев назад

      Same question. Did u find an answer

  • @tschuhmann1275
    @tschuhmann1275 3 года назад +3

    Great video at first! What do you think about not doing the calculation via the covariance-matrix but adding up the daily stock-returns depending on their allocation in the portfolio and just calculating the volatility and mean return of the created portfolio?

  • @saheedfalola3033
    @saheedfalola3033 3 года назад

    Do we need any adjustments for stocks listed on the TSX e.g. Shopify (SHOP)? AX. is giving error. Thanks !

  • @joeygsteez
    @joeygsteez 2 года назад

    I'm not absolutely positive if this is true, but I believe that you can remove the entire line that has stock = [stock+" .AX" for stock in stocklist] and change the final line from print(getdata(stock, start=startDate, end=endDate)) to print(getdata(stocklist, start=startData, end=endData)). I came to this conclusion because I kept getting an error in pycharm telling me that it didn't understand the symbols with .AX at the end. Once I removed the .AX line and changed the final line it interpreted the code and created the model. If you can confirm my suspicion or correct me that would be great, Thanks.

  • @ivannikonov3047
    @ivannikonov3047 Год назад +1

    Can't understand why we use weighted sum of mean returns multiplied by amount of days. Shouldn't we use 1 * (1 +mean returns)^days_in_period ??

  • @richardvdoost
    @richardvdoost 2 года назад +2

    Amazing series, thanks for sharing!
    I was wondering about whether you should be working with the log returns instead of percentage returns? Because taking the average of percentage returns doesn't really make sense (I could be wrong). Or is it just because the daily returns are usually so small that it doesn't really make a difference?

    • @josvandeneynde5849
      @josvandeneynde5849 Год назад +1

      Daily log returns are approximately equal to simple returns (can be proofed by a Taylor series expansion of the function ln(1+x) ). It is allowed to sum daily log return to get a multi period return (properties of logarithms). So the average daily simple return equals the average daily log return and can thus be used to compute the yearly return as he does in the video.

  • @FelipeFoltran
    @FelipeFoltran 9 месяцев назад

    Still works in 2023, with minor tweaks to the code (especially using yfinance instead of get_data_yahoo).

  • @MA-qm7yv
    @MA-qm7yv Год назад

    Hello, thanks for the video but could you please explain why we use .T after weights ? It does not work when I add it
    Thanks !

    • @davidgeuens5236
      @davidgeuens5236 4 месяца назад

      it stands for "transpose", you have to transpose the weights matrix in order to multiply it with the covariance matrix, Hope this is still relevant for you one year later

  • @johannesambaye7710
    @johannesambaye7710 3 года назад +1

    I have a little problem i get the data from reuter and download it to first in excel and then i use python. I can not recreate this so well

    • @QuantPy
      @QuantPy  3 года назад

      I believe Reuters has a python API call which will get your data directly into a pandas dataframe. Just declare that you want the Close price column and you're good to go. Hopefully that helps

  • @riocma
    @riocma 2 года назад

    Hey Mate, How can I fix this error?
    SymbolWarning: Failed to read symbol: 'CBA.AX', replacing with NaN.
    'No data fetched using 'YahooDailyReader'

    • @QuantPy
      @QuantPy  2 года назад +1

      Try updating pandas_datareader
      pip install -upgrade pandas-datareader

  • @johannesambaye7710
    @johannesambaye7710 3 года назад +1

    Could I get all your code. On your website code is not completely available but only partially. I would be very grateful to you

    • @QuantPy
      @QuantPy  3 года назад +2

      Sorry Johannes, working at putting together a github account for this youtube page. But for now all the complicated functions are on website, and the rest you'll find by watching the video's

  • @chriskeo392
    @chriskeo392 3 года назад +2

    Why don't we use adjusted close?
    What's the difference? Thanks man

    • @chriskeo392
      @chriskeo392 3 года назад

      Also can you explain the returns and std at the end? What was impact of the output on the portfolio? Pretty much how you explain that to the investor.

    • @QuantPy
      @QuantPy  3 года назад +1

      Closing price represents the stocks price that is quoted at the end of a trading day. Adjusted closing price takes into account after-hours pricing (out-side of exchange hours) and other corporate actions like dividends ect. Investopedia is probably a good reference here: www.investopedia.com/ask/answers/06/adjustedclosingprice.asp

  • @aarondelarosa3146
    @aarondelarosa3146 Год назад

    Excellent. You forgot to plot Efficient Frontier.

  • @stelios83
    @stelios83 3 года назад

    can you please do a similar video for 10-20 stocks. Under my python code my EF loses its carvature the more stocks i add.

    • @gabrielageraldo8961
      @gabrielageraldo8961 2 года назад

      did you find a solution? It's happening to me too...

    • @QuantPy
      @QuantPy  2 года назад

      If by this you mean the EF black dotted line moves left ‘no longer touching’ the simulated portfolios, this is of course expected. In the simulations each weighting is greater than 0. In the EF scipy optimisation function a weighting of 0 this allowed. This is expected.

    • @gabrielageraldo8961
      @gabrielageraldo8961 2 года назад

      @@QuantPy Thanks for answering! In my case I had this problem because i was using daily returns and annualized risk. Now I think is working.
      Anyway thank you again, your videos are helping a lot! =)

  • @johannesambaye7710
    @johannesambaye7710 3 года назад +1

    Which Editor are you using ?

    • @QuantPy
      @QuantPy  3 года назад +1

      Visual Studio Code

  • @damneddude8299
    @damneddude8299 2 года назад

    Question: the timedelta we use is 365 and the portfolio performance is calculated on 252 days, is it correct or should both of them have the same number of days?

    • @QuantPy
      @QuantPy  2 года назад

      These don’t need to be the same. 252 is for the number of trading days per year so you get annualised numbers. Time delta is just how far we’ve chosen our data range to go back. This was in days

  • @greenpumpkin172
    @greenpumpkin172 3 года назад

    nice, instead of np.dot, use @ operator for clarity :-)

  • @noelsmith399
    @noelsmith399 Год назад

    copied his code word for word and it didn't work