PORTFOLIO
Data Science & Analysis - Statistics - Programming
by Paweł Tokarski

The project's objective was to create a diversified investment portfolio using stocks from different companies and industries. Its risk level was to be analyzed, with a focus on identifying markets (developed or emerging) with lower risks and suitable for investment.
To achieve this goal, I studied ETFs that measure market indices. Of course, the macroeconomic situation was also taken into account later.
After thorough analysis, I concluded that investing in developed markets would be a better opportunity. As such, I selected well-known American brands such as Microsoft, Amazon, and Google (around a dozen in total).
The materials and code can be found at the following link:
https://github.com/PawelTokarski95/Portfolio-Risk-in-R-
​
I also had to assess the risk, so for that, measures such as Value at Risk and Expected Shortfall are needed, but we can discuss them later.
​
I will not refer to the details of the code here, but there are a few issues worth discussing.
As for the data itself, the process looked as follows (in short):
-
I downloaded the appropriate ETFs with stock indices in a 'for' loop and checked their level of volatility using my own function. It turned out that the developed countries market is characterized by less volatility.
-
The stock prices of companies were also downloaded in a loop (the most turbulent period and appropriate for risk research - a 3-year period in weekly frequencies) and their volatility was also examined.
-
Rates of return for stock companies were calculated
-
Next, an investment portfolio was created with the appropriate weights: Tickery such as: "MSFT", "WMT", "TSLA", "XOM", "ORCL" received equal 20% shares in the portfolio. The examined portfolio, which we expose to risk, is worth 100.000 dollars.
In this case, it is worth mentioning something like Value at Risk and Expected Shortfall. Value at Risk (VaR) measures the boundary level of losses at a certain probability level. It is a commonly used measure for calculating risk. Expected Shortfall (ES) is a measure of the average loss that can be expected within Value at Risk, so you could say it is the 'worst loss' scenario.
Of course, before creating VaR, I had to measure the level of variation of values in order to create the appropriate distribution. The results are presented on the box plot. As can be seen, there is a certain symmetry:
​
​
​
​
​
​
​
​
​
​
​
​
​
Finally, I also calculated both the Value at Risk and the Expected Shortfall for the portfolio. The Value at Risk at a probability level of 5% is approximately 6000 dollars, while the expected shortfall is 11.000 dollars.
Here is a chart of the Value at Risk:
​
​
​
​
​
​
​
​
​
​
​
​
​
Additionally, I added a histogram plot to show that the frequency is closer to the average than to a smaller number of outliers in the Value at Risk area.
In summary, portfolio risk is rather high in context of measurements, especially if the potential investor wants to invest in the assets in the future. As seen in the past, there can be various unexpected macroeconomic situations such as the coronavirus pandemic and the war in Ukraine. That is the main issue - high unpredictability today. Therefore, there should be an awareness of potential threats.
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​

