Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Portfolio Returns | Portfolio Analysis Basics
Introduction to Financial Portfolio Management with Python
course content

Conteúdo do Curso

Introduction to Financial Portfolio Management with Python

Introduction to Financial Portfolio Management with Python

1. Portfolio Analysis Basics
2. Portfolio Optimization Basics
3. Factor Investing

Portfolio Returns

Previously, we discussed the basic aspects of investing and portfolio analysis.

In the coming two chapters, we will explore two key concepts for an entire portfolio analysis - return and risk, beginning from the first.

What is Return?

It represents the profitability of an investment and can be either positive or negative, depending on whether the investment has increased or decreased in value.

Common Types of Return

Absolute Return

The simplest return to compute - is absolute return, which is simply - just the difference between the current price of an asset and its earlier price.

Here:

  • P_t - the current price of an asset;
  • P_t-1 - the price of an asset in the previous moment.

Here is a code example of computing absolute return:

1234567891011121314
# 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'], columns = ['Apple', 'Meta', 'Amazon'], data = [[220.14, 499.60, 170.56], [220.88, 505.90, 176.25], [219.74, 504.56, 179.40]]) # Printing basic DataFrame `stocks` print ('Stock data: \n') print(stocks) # Printing DataFrame with values of corresponding absolute return print ('Absolute return: \n') print(stocks.diff())
copy

However, this type of return has a significant disadvantage: it doesn’t account for the scale of the asset’s price.

To understand, why scale matters, let's consider an example.

Relative Return

A significantly better measure of profit is relative return, which computes price changes relatively to the previous value of an asset:

Here, the notation is just the same as in the case of absolute return.

Also, in the rest of the course, we will specifically consider relative return by saying return.

Here is a code example of computing return:

1234567891011121314
# 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'], columns = ['Apple', 'Meta', 'Amazon'], data = [[220.14, 499.60, 170.56], [220.88, 505.90, 176.25], [219.74, 504.56, 179.40]]) # Printing basic DataFrame `stocks` print ('Stock data: \n') print(stocks) # Printing DataFrame with values of corresponding return print ('Return: \n') print(stocks.pct_change())
copy

Return of Portfolio

Returning to portfolio analysis, it's important to note that the portfolio return is calculated by considering the return of each individual asset within the portfolio and their corresponding weights:

Here:

  • R_p - total return of portfolio at the current moment;
  • R_i - the corresponding return of an asset i;
  • w_i - weight of an asset i.

Here is a code example of computing portfolio's return:

1234567891011121314151617181920
# Importing necessary library import pandas as pd import numpy as np # 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'], columns = ['Apple', 'Meta', 'Amazon'], data = [[220.14, 499.60, 170.56], [220.88, 505.90, 176.25], [219.74, 504.56, 179.40]]) # Defining list of portfolios weights weights = [0.5185185185185185, 0.19753086419753088, 0.28395061728395066] # Printing basic DataFrame `stocks` print ('Stock data: \n') print(stocks) # Printing DataFrame with returns print ('Return: \n') print(stocks.pct_change()) # Printing Series with portfolio's returns print ('Portfolio return: \n') print(np.sum(stocks.pct_change()*weights, axis = 1))
copy

Cumulative Return

The last important concept to cover in this chapter is the cumulative return.

It represents the total performance over time, indicating how much the price has changed since the start.

Here is an example of code for calculating it:

1234567891011121314151617181920
# Importing necessary library import pandas as pd import numpy as np # 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'], columns = ['Apple', 'Meta', 'Amazon'], data = [[220.14, 499.60, 170.56], [220.88, 505.90, 176.25], [219.74, 504.56, 179.40]]) # Defining list `weights` of portfolis weights weights = [0.5185185185185185, 0.19753086419753088, 0.28395061728395066] # Printing basic DataFrame `stocks` print ('Stock data: \n') print(stocks) # Printing DataFrame with returns print ('Return: \n') print(stocks.pct_change()) # Printing DataFrame with cumualtive returns print ('Cumulative return: \n') print((1 + stocks.pct_change()).cumprod())
copy

Why do we take relative change as a return instead of absolute?

Selecione a resposta correta

Tudo estava claro?

Seção 1. Capítulo 3
We're sorry to hear that something went wrong. What happened?
some-alt