logo image of EssayBoard website
x
feature image of Using Daily Mean Percent Return To Measure The Performance of A Stock

Using Daily Mean Percent Return To Measure The Performance of A Stock   

Taking a Udemy course "Python for Finance and Algorithmic Trading with QuantConnect", and I'm on the part where the instructor emphasizes normalizing measurements of returns.  This is obvious if one thinks about it clearly!  A return with a gain in absolute dollar amount for one stock versus another stock could be the same, but the initial amount of dollars and time that you spent to invest in a stock might tell a different story.  For example, let's say you bought one share of stock ABC for $100 and one share of stock XYZ for $3000, but at the end of the year, both return the same exact dollar amount which is $300.  This means stock ABC is now worth $400/share, and stock XYZ is now worth $3300/share.  Which stock do you think is a better gain?  Obviously, stock ABC because you spent less amount of dollars (time is the same for both stocks)!  Imagine instead of spending $3000 to buy stock XYZ just to gain $300 at the end of the year, you could have bought all $3000 worth of ABC stock and gained a whole lot more, right?  This is why he emphasizes in the course video that we need to normalize the measurements of returns.  For this instance, we could use percent return and do away with absolute dollar return.

Percent return could be calculated as (Price(t) - Price(t-1)) / Price(t-1) * 100.  The Price(t) is the Adjusted Closing Price for let's say stock ABC at the end of 2022.  Price(t-1) could be the initial share amount that was used to buy the shares of ABC.  Remember, to make things simple we just calculate a return for a single share.  So, for stock ABC, a single share would yield a 300% return.  After using the percent return formula to calculate the return of a single share of stock XYZ, it's just a measly 10% return.  This means the investment in stock ABC is definitely a better investment.

We can also calculate the daily percent return for any stock, and then calculate the mean (average) of such a stock over a window of timeframe.  This could help us measure the performance of such a stock over a window of timeframe.  For example, the code below will help us calculate how a single share of TESLA with the ticker symbol TSLA performed in 2022.

import yfinance as yfinance

tesla = yf.download('TSLA', start='2022-01-01', end='2022-12-31')
mean_percent_return_2022 = tesla['Adj Close'].pct_change().mean() * 100
print(mean_percent_return_2022)

If the math is correct and my code is correct, the print statement should return -0.384749817449449.  This means on average, each day for the whole year of 2022, any single share of TESLA is underperformed.  

If you ask Chat GPT (Dec. 15th of 2022 version) what is percent change for Pandas in Python, it would answer like this:

"""
In pandas, the pct_change() function is used to compute the percentage change between the elements in a DataFrame or Series. It is similar to the diff() function, which computes the difference between the elements, but pct_change() expresses the difference as a percentage of the previous element.

For example, consider the following DataFrame:

Copy code
"""
import pandas as pd
df = pd.DataFrame([100, 120, 130, 110, 90])

# To compute the percentage change between the elements in this DataFrame, you can use the 
# pct_change() function:

# Copy code
df.pct_change()

# The resulting output will be:

# Copy code
#          0
# 0        NaN
# 1       0.2
# 2       0.1
# 3      -0.2
# 4      -0.2
# Here, the percentage change is calculated as follows:

"""
(120 - 100) / 100 = 0.2
(130 - 120) / 120 = 0.1
(110 - 130) / 130 = -0.2
(90 - 110) / 110 = -0.2
The first element (index 0) is NaN, because there is no previous element to compare it to.

You can also specify the axis parameter to compute the percentage change along a particular axis. For example, to compute the percentage change along the columns of a DataFrame, you can set axis=1.
"""

If you ask Chat GPT what are the use cases for percent_change(), it would answer like this:

"""
The pct_change() function is commonly used to analyze the percentage change in a series of data over time, such as stock prices, exchange rates, etc. This can help you understand how a particular data series is evolving and identify trends or patterns in the data.

For example, if you are analyzing stock prices, you can use pct_change() to compute the percentage change in the stock price from one day to the next. This can help you identify whether the stock price is increasing or decreasing over time, and by how much.

Other use cases for pct_change() include:

Analyzing the percentage change in sales or revenue over time.
Analyzing the percentage change in inflation or consumer price indices over time.
Analyzing the percentage change in exchange rates between different currencies.
Analyzing the percentage change in population or demographic data over time.
Overall, pct_change() can be a useful tool for analyzing and understanding changes in data over time, and for identifying trends and patterns in the data.
"""

If you ask Chat GPT what are the use cases for daily mean percent return, it would answer like this:

"""
The daily mean percentage return is a measure of the average daily return of an investment or portfolio, expressed as a percentage. It is calculated by dividing the total return over a period of time (e.g., one year) by the number of days in that period, and expressing the result as a percentage.

There are several use cases for daily mean percentage return, including:

Comparing the performance of different investments or portfolios. By calculating the daily mean percentage return for each investment or portfolio, you can compare their performance and determine which one has performed better over a given period of time.

Analyzing the risk and return of an investment or portfolio. By calculating the daily mean percentage return, you can get a sense of the average return you can expect from an investment or portfolio on a daily basis. This can help you understand the potential risk and reward of an investment, and decide whether it is a good fit for your investment goals.

Evaluating the performance of a fund manager or investment advisor. By calculating the daily mean percentage return for a managed investment or portfolio, you can evaluate the performance of the fund manager or advisor and determine whether they are meeting their performance goals.

Planning for the future. By understanding the daily mean percentage return of an investment or portfolio, you can get a sense of the potential return you can expect in the future, and use this information to plan your financial goals and investments accordingly.

Overall, the daily mean percentage return is a useful metric for understanding the performance and risk-reward tradeoff of an investment or portfolio.
"""

So, if you ask Chat GPT if it's true that daily mean percent return calculates the return amount of any single stock for each day of the whole year if the timeframe is a whole year, it would answer like this:

"""
Yes, that's correct! The daily mean percentage return is a measure of the average daily return of an investment or portfolio over a given period of time. So if you calculate the daily mean percentage return for a stock like TSLA, it will give you the average daily return of the stock over a particular period of time (e.g., one year).

For example, if you calculate the daily mean percentage return for TSLA over the course of one year, it will give you the average daily return of the stock for all 365 days in that year. This can be useful for understanding the overall performance of the stock over the course of the year, and for identifying trends or patterns in the data.

To calculate the daily mean percentage return for TSLA, you would need to get the stock price data for TSLA over the period of time you are interested in (e.g., one year), and then use the pct_change() function in pandas to compute the percentage change in the stock price from one day to the next. You can then take the mean of these percentage changes to get the daily mean percentage return for the stock.
"""

In summary, if I understand everything correctly, it does mean that the calculation I did for Tesla earlier means if anyone invests in Tesla in 2022, each day a share of Tesla is losing about -0.384749817449449 in percentage.  I guess you could convert this percentage into an absolute dollar amount for a single share of Tesla in the whole year of 2022 to see how much money you would lose if multiply this by all of the Tesla shares you hold.  Anyway, I'm not writing this blog post for the sake of writing it because I want to write all of this out into a blog post so it could be a reminder for me if I ever forget how to calculate the percent return (either daily mean percent return or just a simple percent return).

profile image of Vinh Nguyen

Famous quote by:   
Oscar Wilde

“To live is the rarest thing in the world. Most people exist, that is all.”

Post Comments