11.2 Volatility of a 2-stock portfolio
11.2 Volatility of a 2-stock portfolio
To compute the standard deviation of a portfolio, we cannot rely on the weighted average. We have to look to the covariances.

\(\sigma^2_1\) = variance of asset 1.
\(\sigma^2_2\) = variance of asset 2
\(\sigma_{12}\) = covariance between assets 1 and 2
11.2 Volatility of a 2-stock portfolio
Covariance is the product of the assets’ Sd and their correlation.

\[\sigma_{12} = \sigma_1 \times \sigma_2 \times \rho_{12}\]

Covariance is the expected product of the deviations of two returns from their means.

\[Cov(R_i,R_j) = E[(R_i-E[R_i]) \times (R_j-E[R_j]) ]\]

When using historical data:

\[Cov(R_i,R_j) = \frac{1}{T-1} (R_i-\tilde{R_i} ) \times (R_j-\tilde{R_j} )\]

Correlation:

\[Corr(R_i,R_j) = \frac{Cov(R_i,R_j)}{Sd(R_i)\times Sd(R_j) }\]

11.2 Volatility of a 2-stock portfolio
Therefore, the portfolio variance is:

\[var = (x_1^2 \times \sigma_1^2) + (x_2^2 \times \sigma_2^2) + 2(x_1 \times x_2 \times \sigma_1 \times \sigma_2 \times \rho_{12})\]

If \(\rho_{12} = 0.26\)

\[(0.4^2 \times 26.6^2) + (0.6^2 \times 27.9^2) + 2(0.4 \times 0.6 \times 26.6 \times 27.9 \times 0.26) = 486.1\]

The standard deviation of the portfolio is \(\sqrt{486.1}= 22\%\) , which is lower than 26.6% and 27.9%.

11.2 Volatility of a 2-stock portfolio
Covariance and Correlation

Let’s remember the basics about correlation.

11.2 Volatility of a 2-stock portfolio
Covariance and Correlation

These assets have the same historical return and volatility, but they ‘move’ very differently :

For example, when North Air performed well, Text Oil tended to do poorly, and when North Air did poorly, Text oil tended to do well

North Air is not positively correlated with Text Oil.

Consider the portfolio which consists of equal investments in West Air and Tex Oil. The average return of the portfolio is equal to the average return of the two stocks…

…However, the volatility of 5.1% is much less than the volatility of the two individual stocks.

The amount of risk that is eliminated in a portfolio depends on the degree to which the stocks face common risks and their prices move together.

11.2 Volatility of a 2-stock portfolio
R
library (PerformanceAnalytics)
library (yfR)
library (ggplot2)
library (dplyr)
library (tidyr)
library (ggthemes)
library (tidyquant)
library (roll)
library (plotly)
library (ggthemes)
stocks <- c ('BBDC3.SA' , 'PETR3.SA' )
start <- '2010-01-01'
end <- Sys.Date ()
data <- yf_get (tickers = stocks,
first_date = start,
last_date = end)
data<- data[complete.cases (data),]
p<- ggplot (data, aes (ref_date , price_close, group= ticker , color= ticker))+
geom_line () +
labs (x = "" ,
y= 'Closing prices' ,
title= "Two assets returns" ,
subtitle = "Begin 01/01/2010" ) + theme_solarized ()
ggplotly (p)

Python
import yfinance as yf
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy.stats import norm
stocks = ['BBDC3.SA' , 'PETR3.SA' ]
start = '2010-01-01'
end = pd.Timestamp.today().strftime('%Y-%m- %d ' )
data = yf.download(stocks, start= start, end= end)['Close' ]
data = data.dropna()
# plot the data
plt.close()
plt.plot(data.index, data['BBDC3.SA' ], label= 'BBDC3.SA' )
plt.plot(data.index, data['PETR3.SA' ], label= 'PETR3.SA' )
# add title and axis labels
plt.title('Two assets returns' )
plt.xlabel('Date' )
plt.ylabel('Closing prices' )
# add legend
plt.legend()
# display the plot
plt.show()

Same graph using prices in day 1 = $100.

R
stock1 <- subset (data, ticker == stocks[1 ])
stock2 <- subset (data, ticker == stocks[2 ])
stock1$ price_close2 <- stock1$ price_close / stock1$ price_close[1 ] * 100
stock2$ price_close2 <- stock2$ price_close / stock2$ price_close[1 ] * 100
p<- ggplot (stock1, aes (ref_date , price_close2, color= ticker))+
geom_line () +
geom_line (data= stock2) +
labs (x = "" ,
y= 'Closing prices' ,
title= "Two assets returns, Initial price = 100" ,
subtitle = "Begin 01/01/2010" ) + theme_solarized ()
ggplotly (p)