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']
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
@@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!
@@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!
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 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
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 ?😊
💻 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/
I'm so lucky to find this channel! Thank you!
Welcome aboard, I'm glad you found it as well!
Rather than writing a for loop, you can accomplish the same output with:
data = yf.download(tickers, start=startDate, end=endDate)['Adj Close']
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']
absolutly epic
I appreciate it Ron!
How are leap years accounted for if using a static 365 days? I also wanted to say I enjoy your videos!
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
@@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!
@@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!
Hello Ryan,
You calculated range returns taking days = 5
So is this a 5-Day 95 % VaR ?
Yes
I can do this in excel. When I look at the python terminology It seems like just more education witch hunt
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
@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
@@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
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 ?😊