First moment: Mu
You can calculate the average historical return of a stock by using numpy
's mean()
function.
When you are calculating the average daily return of a stock, you are essentially estimating the first moment ( \( \mu \) ) of the historical returns distribution.
But what use are daily return estimates to a long-term investor? You can use the formula below to estimate the average annual return of a stock given the average daily return and the number of trading days in a year (typically there are roughly 252 trading days in a year):
$$ \text{Average Annualized Return} = ( ( 1 + \mu ) ^ {252}) - 1 $$
The StockPrices
object from the previous exercise is stored as a variable.
This exercise is part of the course
Introduction to Portfolio Risk Management in Python
Exercise instructions
- Import
numpy
asnp
. - Calculate the mean of the
'Returns'
column to estimate the first moment ( \( \mu \) ) and set it equal tomean_return_daily
. - Use the formula to derive the average annualized return assuming 252 trading days per year. Remember that exponents in Python are calculated using the
**
operator.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import numpy as np
import ____ as ____
# Calculate the average daily return of the stock
mean_return_daily = ____(StockPrices['Returns'])
print(mean_return_daily)
# Calculate the implied annualized average return
mean_return_annualized = ((____+____)**____)-____
print(mean_return_annualized)