Value at Risk (VaR) In Python: Historical Method

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

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

  • @RyanOConnellCFA
    @RyanOConnellCFA  Год назад +3

    💻 Free Code Here: ryanoconnellfinance.com/value-at-risk-analysis-using-python/
    👨‍💼 My Freelance Financial Modeling Services:
    ► Custom financial modeling solutions tailored for your needs: ryanoconnellfinance.com/freelance-finance-services/

  • @terryliu3635
    @terryliu3635 9 месяцев назад +1

    I'm so lucky to find this channel! Thank you!

    • @RyanOConnellCFA
      @RyanOConnellCFA  7 месяцев назад

      Welcome aboard, I'm glad you found it as well!

  • @BurksAustin
    @BurksAustin Год назад +6

    Rather than writing a for loop, you can accomplish the same output with:
    data = yf.download(tickers, start=startDate, end=endDate)['Adj Close']

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

      Yes, this is a faster way to do it. To reduce the number of lines of code, you replace the code in the box under the section titled "Download the daily adjusted close prices for the tickers" with:
      adj_close_df = yf.download(tickers, start=startDate, end=endDate)['Adj Close']

  • @ron3252
    @ron3252 2 месяца назад +1

    absolutly epic

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

    How are leap years accounted for if using a static 365 days? I also wanted to say I enjoy your videos!

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

      Thank you! Good question, it is not! Although, that is not all that important because whether we look at 3,000 days of historical data or 3,002 days of historical data doesn't really matter much. You could code leap years in if you wanted to though

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

      @@RyanOConnellCFA Thanks! One piece of fun I have had with mine so far is adding an input into the ticker variable so a user could input a stock ticker as a variable and then run the rest of the code to get the results for the particular company based on the input ticker. This has been helpful for jumping back into practical examples, thanks again!

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

      @@farmer5123 That is a very cool application of the code! That could definitely give you an interesting view of the risk of different companies. Great adaptation!

  • @ronitlenka9205
    @ronitlenka9205 3 месяца назад

    Hello Ryan,
    You calculated range returns taking days = 5
    So is this a 5-Day 95 % VaR ?

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

    I can do this in excel. When I look at the python terminology It seems like just more education witch hunt

    • @RyanOConnellCFA
      @RyanOConnellCFA  Год назад +3

      When you are in job and have a process that must be repeated on a daily/weekly basis it is usually much better to do it in Python because once the code is written you just need to either press one button to run the code or have the code run everyday (at say 9 AM) on its own. Coding it in Python rather than Excel will take more time upfront but then will reduce the likelihood of human error and decrease the amount of time spent on the task in the future

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

      @RyanOConnellCFA I got you. But I use power queries in excel. I click refresh and it's done. The sheet is updated with the latest data

    • @RyanOConnellCFA
      @RyanOConnellCFA  Год назад +2

      @@prettywitty9051 Power Query is a pretty cool way to automate things as well! I used that at my last job, not enough to really get any good at it though. One other big advantage Python has is that it can deal with massive amounts of data. Excel sheets max out at just over 1 million rows and some large institutions have a lot more data than that

    • @chuntochu9598
      @chuntochu9598 8 месяцев назад

      Looks very useful and easy understand to use and perform the VaR analysis, however, for some of illiquid investments, say OTC bonds or options, they may not have prices everyday, can this model still be applicable?
      Also,may I know if this model can apply to analyse the VaR for hedge funds with short positions ?😊