Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Understanding Portfolio Returns | Investment Metrics and Portfolio Analysis
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Investors

bookUnderstanding Portfolio Returns

Understanding how to calculate portfolio return is fundamental for investors who manage multiple assets. The return of a portfolio is not just a simple average of each asset's return. Instead, it is a weighted sum, where each asset's return is multiplied by its proportion (or "weight") in the portfolio. This approach reflects the real-world scenario where you invest different amounts in each asset. By using weights, you can see how the composition of your investments impacts your overall profit or loss. For investors, this matters because it allows you to tailor your exposure to risk and reward by adjusting how much you allocate to each asset.

123456789101112131415
import numpy as np import pandas as pd # Example asset returns for three stocks returns = pd.Series([0.04, 0.07, 0.02], index=["Stock A", "Stock B", "Stock C"]) # Portfolio weights (must sum to 1) weights = np.array([0.5, 0.3, 0.2]) # Calculate portfolio return as weighted sum portfolio_return = np.dot(returns, weights) print(f"Asset returns:\n{returns}") print(f"Weights: {weights}") print(f"Portfolio return: {portfolio_return:.4f}")
copy

To understand the calculation above, think of the weighted average as a way to blend individual asset returns according to how much of your portfolio each one represents. You multiply each asset's return by its weight, then sum the results. In the code, np.dot(returns, weights) efficiently performs this operation: it multiplies each return by its corresponding weight and adds up the products. The sum gives you the overall portfolio return, which reflects both the performance of the assets and how much capital you've allocated to each. This method lets you see the direct impact of your investment choices on your results.

12345678910111213
# Adjusting weights to see the impact on portfolio return # New weights: increase allocation to Stock B new_weights = np.array([0.3, 0.6, 0.1]) # Ensure weights sum to 1 assert np.isclose(new_weights.sum(), 1.0) # Recalculate portfolio return new_portfolio_return = np.dot(returns, new_weights) print(f"New weights: {new_weights}") print(f"New portfolio return: {new_portfolio_return:.4f}")
copy

1. What does a portfolio weight represent?

2. How does changing the weight of an asset affect the portfolio return?

3. Which mathematical operation is used to combine asset returns and weights?

question mark

What does a portfolio weight represent?

Select the correct answer

question mark

How does changing the weight of an asset affect the portfolio return?

Select the correct answer

question mark

Which mathematical operation is used to combine asset returns and weights?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 1

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

bookUnderstanding Portfolio Returns

Stryg for at vise menuen

Understanding how to calculate portfolio return is fundamental for investors who manage multiple assets. The return of a portfolio is not just a simple average of each asset's return. Instead, it is a weighted sum, where each asset's return is multiplied by its proportion (or "weight") in the portfolio. This approach reflects the real-world scenario where you invest different amounts in each asset. By using weights, you can see how the composition of your investments impacts your overall profit or loss. For investors, this matters because it allows you to tailor your exposure to risk and reward by adjusting how much you allocate to each asset.

123456789101112131415
import numpy as np import pandas as pd # Example asset returns for three stocks returns = pd.Series([0.04, 0.07, 0.02], index=["Stock A", "Stock B", "Stock C"]) # Portfolio weights (must sum to 1) weights = np.array([0.5, 0.3, 0.2]) # Calculate portfolio return as weighted sum portfolio_return = np.dot(returns, weights) print(f"Asset returns:\n{returns}") print(f"Weights: {weights}") print(f"Portfolio return: {portfolio_return:.4f}")
copy

To understand the calculation above, think of the weighted average as a way to blend individual asset returns according to how much of your portfolio each one represents. You multiply each asset's return by its weight, then sum the results. In the code, np.dot(returns, weights) efficiently performs this operation: it multiplies each return by its corresponding weight and adds up the products. The sum gives you the overall portfolio return, which reflects both the performance of the assets and how much capital you've allocated to each. This method lets you see the direct impact of your investment choices on your results.

12345678910111213
# Adjusting weights to see the impact on portfolio return # New weights: increase allocation to Stock B new_weights = np.array([0.3, 0.6, 0.1]) # Ensure weights sum to 1 assert np.isclose(new_weights.sum(), 1.0) # Recalculate portfolio return new_portfolio_return = np.dot(returns, new_weights) print(f"New weights: {new_weights}") print(f"New portfolio return: {new_portfolio_return:.4f}")
copy

1. What does a portfolio weight represent?

2. How does changing the weight of an asset affect the portfolio return?

3. Which mathematical operation is used to combine asset returns and weights?

question mark

What does a portfolio weight represent?

Select the correct answer

question mark

How does changing the weight of an asset affect the portfolio return?

Select the correct answer

question mark

Which mathematical operation is used to combine asset returns and weights?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 1
some-alt