# finding the monthly covariance matrix given daily covariance matrix

consider the following problem i am trying to find the monthly covariance matrix given daily data. i have the following codeimport datetime

import pandas as pd
import yfinance as yf
import numpy as np

tickers = ['AAPL', 'AMZN', 'XOM']
start_date1 = datetime.date(2010, 1, 2)
end_date1 = datetime.date(2019, 12, 31)

frames = [v for _, v in daily_data1.groupby(pd.Grouper(freq='M'))]

for month in frames:
cov_matrix = (month.pct_change().apply(lambda x: np.log(1 + x)).cov())


so i think i would multiply the cov_matrix with the length of the given month by i am unsure if its that easy so multiply the cov_matrix*len(month)? if someone could confirm it. Thanks in advance

• IMO the best way to find the monthly covariance matrix is to downsample the daily data to monthly and then directly compute the covariance on that monthly data. Oct 29, 2022 at 10:52
• how do I do it. not sure what you mean. will remind you that the above is a part of a more extensive code where I am using daily data I have just deleted all unnecessary for my question Oct 29, 2022 at 11:10
• @Robert you can downsample your daily data to monthly, using one line of Python code: daily_data1.resample('M').last() will give you the last day of each month for the corresponding daily_data1 dataframe. Now transform said monthly data to returns and compute the (rolling) covariance matrix on that data.
– Pleb
Oct 30, 2022 at 21:09
• The nice part about @nbbo2 suggestion is that alignment and weak auto correlation and cross correlation effects are less of a problem for monthly observations. The daily alignment (perhaps of last trade) is less important for returns spanning a month. The effects of correlation are included in the monthly returns. See also: quant.stackexchange.com/questions/71574/… Dec 1, 2022 at 18:10