Market Risk
Annualizing Metrics¶
When we talk about equity markets, we often quote things in terms of an annual basis. We don’t want the daily return but rather we want the annual return. The same goes for the measures of risk. Let’s examine how we annualize both.
Annualized Return¶
As we saw from prior lessons, annualizing a return can be done by taking the HPR and applying this formula:
$$ CAGR = (HPR + 1)^{1/t} – 1$$
where
$ CAGR = \text{Compound Annual Growth Rate} $
$ HPR = \text{Holding Period Return} $
$ t = \text{The number of years for the HPR} $
There is one caveat when using equity returns… there are not returns on weekends or trading holidays! So you can’t just take the number of days and divide by 365. Instead you will need to do one of two things:
- Find the number of days between the first and last return and divide this number by 365.
- Divide the total number of days with returns by an approximation for the number of trading days like 252.
In the example, there were no dates given so we won’t be able to do it the first way. Instead we assume 252 trading days. So the number of years for our sample can be calculated below as:
#Calculate number of years
t = len(market_returns) / 252
print(t)
With the number of years handy, we just need to apply the formula.
#Find the CAGR
CAGR = (1 + HPR) ** (1/t) - 1
print(CAGR)
Annualizing Variance¶
Variance has the following property in math which makes this piece easier when we are sampling N days:
$$ VAR(X_N) = N \cdot VAR(X) $$
where
$ N = \text{Number of samples} $
$ X = \text{Asset X} $
$ X_N = \text{N samples of asset X} $
It applys in a parallel way to standard deviation where the c comes out as a square root:
$$ STD(X_N) = \sqrt{N} \cdot STD(X) $$
where
$ N = \text{Number of samples} $
$ X = \text{Asset X} $
$ X_N = \text{N samples of asset X} $
To annualize these risk metrics, we want to see what the variance is with a year of trading days. Again we use the approximation of 252.
$$ VAR( \cdot X_{252}) = 252 \cdot VAR(X) $$$$ STD( \cdot X_{252}) = \sqrt{252} \cdot STD(X) $$
So for the annual standard deviation and variance, the code below shows the simple constants that we must multiply in.
#Find the annual variance + standard deviation
var_pop_annual = var_pop * 252
std_pop_annual = std_pop * 252 ** .5
print(var_pop_annual)
print(std_pop_annual)
Once again, just ignore the code below since it is setting up for the next part of the lesson.
#Create the stock return
np.random.seed(2)
stock_returns = np.random.normal(0.0001, .01, 500) + .8 * market_returns
#Use P to denote current price
P = 100
#The ts variable will hold the time series of the asset price, at time 0 it is equal to P
ts_stock = [P]
#Iterate through all the returns
for r in stock_returns:
#The new stock value is P * (1+r)
P = P * (1+r)
#Append to the time series
ts_stock.append(P)