Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Measuring Portfolio Risk and Return | Risk Analysis and Portfolio Optimization
Python for Financial Analysts

bookMeasuring Portfolio Risk and Return

Understanding how to measure the risk and return of a portfolio is a cornerstone of modern portfolio theory. When you invest in multiple assets, you need to know not just what each asset might earn, but also how their returns interact. The expected return of a portfolio tells you the average outcome you might anticipate, while risk—often measured as standard deviation—captures the uncertainty or variability around that average. Diversification, which means spreading investments across various assets, plays a crucial role in managing risk. By combining assets that do not move exactly together, you can often reduce the overall risk of the portfolio without necessarily sacrificing return.

123456789101112131415161718192021
import numpy as np # Expected returns for two assets returns = np.array([0.08, 0.12]) # 8% and 12% expected returns weights = np.array([0.6, 0.4]) # 60% in asset 1, 40% in asset 2 # Covariance matrix between the two assets cov_matrix = np.array([ [0.04, 0.018], # variances and covariance [0.018, 0.09] ]) # Portfolio expected return portfolio_return = np.dot(weights, returns) # Portfolio standard deviation (risk) portfolio_variance = np.dot(weights.T, np.dot(cov_matrix, weights)) portfolio_std = np.sqrt(portfolio_variance) print("Expected Portfolio Return:", round(portfolio_return, 4)) print("Portfolio Standard Deviation (Risk):", round(portfolio_std, 4))
copy

To calculate a portfolio's expected return, you multiply each asset's expected return by its portfolio weight and sum the results. For risk, the calculation is more involved: you must account for both the individual variances of each asset and the way the assets' returns move together, which is captured by their covariances. The formula for portfolio variance (risk) is:

  • Portfolio Expected Return: the sum of (weight of asset × expected return of asset) for all assets;
  • Portfolio Variance: the sum of (weight_i × weight_j × covariance between asset i and asset j) for all combinations of assets.

In the two-asset example above, the weights and expected returns are used to find the average return, while the covariance matrix is used to calculate how the assets’ returns interact, leading to the overall portfolio risk.

1234567891011121314151617181920212223
import pandas as pd # Expected returns for four assets returns = pd.Series([0.07, 0.09, 0.13, 0.11], index=["A", "B", "C", "D"]) weights = pd.Series([0.25, 0.25, 0.30, 0.20], index=["A", "B", "C", "D"]) # Covariance matrix for four assets cov_matrix = pd.DataFrame([ [0.025, 0.010, 0.012, 0.009], [0.010, 0.040, 0.014, 0.011], [0.012, 0.014, 0.060, 0.016], [0.009, 0.011, 0.016, 0.035] ], columns=["A", "B", "C", "D"], index=["A", "B", "C", "D"]) # Portfolio expected return portfolio_return = (weights * returns).sum() # Portfolio variance and standard deviation portfolio_variance = np.dot(weights, np.dot(cov_matrix, weights)) portfolio_std = np.sqrt(portfolio_variance) print("Expected Portfolio Return:", round(portfolio_return, 4)) print("Portfolio Standard Deviation (Risk):", round(portfolio_std, 4))
copy

1. What is the formula for calculating the expected return of a portfolio?

2. How does diversification affect portfolio risk?

3. Why is standard deviation used as a measure of risk in finance?

question mark

What is the formula for calculating the expected return of a portfolio?

Select the correct answer

question mark

How does diversification affect portfolio risk?

Select the correct answer

question mark

Why is standard deviation used as a measure of risk in finance?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 1

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain how diversification reduces risk in a portfolio?

What does the covariance matrix represent in these calculations?

How would the results change if the asset weights were different?

bookMeasuring Portfolio Risk and Return

Свайпніть щоб показати меню

Understanding how to measure the risk and return of a portfolio is a cornerstone of modern portfolio theory. When you invest in multiple assets, you need to know not just what each asset might earn, but also how their returns interact. The expected return of a portfolio tells you the average outcome you might anticipate, while risk—often measured as standard deviation—captures the uncertainty or variability around that average. Diversification, which means spreading investments across various assets, plays a crucial role in managing risk. By combining assets that do not move exactly together, you can often reduce the overall risk of the portfolio without necessarily sacrificing return.

123456789101112131415161718192021
import numpy as np # Expected returns for two assets returns = np.array([0.08, 0.12]) # 8% and 12% expected returns weights = np.array([0.6, 0.4]) # 60% in asset 1, 40% in asset 2 # Covariance matrix between the two assets cov_matrix = np.array([ [0.04, 0.018], # variances and covariance [0.018, 0.09] ]) # Portfolio expected return portfolio_return = np.dot(weights, returns) # Portfolio standard deviation (risk) portfolio_variance = np.dot(weights.T, np.dot(cov_matrix, weights)) portfolio_std = np.sqrt(portfolio_variance) print("Expected Portfolio Return:", round(portfolio_return, 4)) print("Portfolio Standard Deviation (Risk):", round(portfolio_std, 4))
copy

To calculate a portfolio's expected return, you multiply each asset's expected return by its portfolio weight and sum the results. For risk, the calculation is more involved: you must account for both the individual variances of each asset and the way the assets' returns move together, which is captured by their covariances. The formula for portfolio variance (risk) is:

  • Portfolio Expected Return: the sum of (weight of asset × expected return of asset) for all assets;
  • Portfolio Variance: the sum of (weight_i × weight_j × covariance between asset i and asset j) for all combinations of assets.

In the two-asset example above, the weights and expected returns are used to find the average return, while the covariance matrix is used to calculate how the assets’ returns interact, leading to the overall portfolio risk.

1234567891011121314151617181920212223
import pandas as pd # Expected returns for four assets returns = pd.Series([0.07, 0.09, 0.13, 0.11], index=["A", "B", "C", "D"]) weights = pd.Series([0.25, 0.25, 0.30, 0.20], index=["A", "B", "C", "D"]) # Covariance matrix for four assets cov_matrix = pd.DataFrame([ [0.025, 0.010, 0.012, 0.009], [0.010, 0.040, 0.014, 0.011], [0.012, 0.014, 0.060, 0.016], [0.009, 0.011, 0.016, 0.035] ], columns=["A", "B", "C", "D"], index=["A", "B", "C", "D"]) # Portfolio expected return portfolio_return = (weights * returns).sum() # Portfolio variance and standard deviation portfolio_variance = np.dot(weights, np.dot(cov_matrix, weights)) portfolio_std = np.sqrt(portfolio_variance) print("Expected Portfolio Return:", round(portfolio_return, 4)) print("Portfolio Standard Deviation (Risk):", round(portfolio_std, 4))
copy

1. What is the formula for calculating the expected return of a portfolio?

2. How does diversification affect portfolio risk?

3. Why is standard deviation used as a measure of risk in finance?

question mark

What is the formula for calculating the expected return of a portfolio?

Select the correct answer

question mark

How does diversification affect portfolio risk?

Select the correct answer

question mark

Why is standard deviation used as a measure of risk in finance?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 1
some-alt