Covariance measures the directional relationship between the return on two assets.
Covariance is used in portfolio theory to determine what assets to include in the portfolio.
Formula to calculate covariance.

x is the data value of x
y is the data value of y
μx is the mean of x
μy is the mean of y
N is the number of data values
Example:
Suppose an analyst observed the behavior of stock x and y. If the return of stock x is 2000 and the mean is 150, calculate the covariance if the return of stock y us 1500 and its mean is 120 when N is 5.
Since we already have the return in total, we do not need to do any summation, we will just plug our values in the formula.
