To calculate covariance, choose two stocks and a time frame, calculate the average price for each stock over the time frame, find the deviation of each stock, multiply the two deviations together, add the results, and divide by the total number of days. Calculating an investment covariance requires a list of historical prices, as it is a statistic that looks at historical prices to determine the relationship between two stocks or two bundles of stocks.Continue Reading
Decide the two stocks you want to analyze and the time frame from which you want to pull your data. If you are using daily stock prices, the past six months suffices. If you are using weekly or monthly stock prices, go back at least one year to determine covariance.
Calculate the average price for each stock over the chosen time period. Add up all the prices of both stocks individually, and divide the result by the number of business days in the time frame. These calculations provide the respective means of both stocks. To find the deviation, subtract the stock price for each day from the mean price of the stock.
With your two sets of data (daily variation and average stock price), multiply the deviation of stock A by the deviation of stock B for each business day within the time frame. To find the covariance of the stock, add these results, and divide them by the total number of business days.