Contenido del Curso
Introduction to Financial Portfolio Management with Python
Introduction to Financial Portfolio Management with Python
Measuring Risk of Portfolio
What is Risk?
Next, let's discover the second key concept in portfolio analysis - risk.
First of all, let's define what risk is.
Practically, investing always involves risk because asset prices fluctuate frequently.
They can fall just as easily as they can rise.
Common Measure of Risk
The question arises: how to measure risk?
Since investing is considered riskier when an asset's price fluctuates more significantly, a common measure of risk is the standard deviation of an asset's returns or corresponding variance.
This is common measure, also known as volatility.
Here is a code example of measuring risk of assets:
# Importing necessary library import pandas as pd # Creating DataFrame `stocks` with values of stock prices of Apple, Meta and Amazon for the period from `2024-09-06` to `2024-09-10` stocks = pd.DataFrame(index = ['2024-09-06', '2024-09-09', '2024-09-10', '2024-09-11'], columns = ['Apple', 'Meta', 'Amazon'], data = [[220.14, 499.60, 170.56], [220.88, 505.90, 176.25], [219.74, 504.56, 179.40], [222.14, 512.20, 184.05]]) # Printing basic DataFrame `stocks` print ('Stock data: \n') print(stocks) # Printing DataFrame with values of corresponding return print ('Return: \n') print(stocks.pct_change()) # Printing Series with measures of risk for each company print ('Risk: \n') print(stocks.pct_change().std())
Risk of Portfolio
After we have covered the key aspects of the risk associated with individual investments, it's time to turn our attention to the risk of an entire portfolio.
We will explore this topic in the following video:
Here is a corresponding Google Colab.
Additionally, there are several other measures of financial risk, some of which we will explore in later chapters of this course.
¿Todo estuvo claro?