How do I measure the correlation between different Adjusted return of different index return in Python

Viewed 14

So this is a very beginner question, but I hope I can receive some help with this. I have the following log returns :

HengSeng["HengSengLogReturns"]=(np.log(HengSeng["Adj Close"])).diff()
NASDAQ["NASDAQLogReturns"]=(np.log(NASDAQ["Adj Close"])).diff()
GermanDax100["GermanDax100LogReturns"]=(np.log(GermanDax100["Adj Close"])).diff()
Netherland25["Netherland25LogReturns"]=(np.log(Netherland25["Adj Close"])).diff()
Europe50["Europe50LogReturns"]=(np.log(Europe50["Adj Close"])).diff()

How would I make a correlation table for each of them?

Although they are all from the same period (2014-now), the different markets can open/close on a different dates so the number of rows of returns is not consistent

I tried to merge them into a single data frame which obviously failed, hence I was unable able to use the

df.corr()

Any help is appreciated

1 Answers

If I understand you correctly, you could compile them after creating the series

HengSeng["HengSengLogReturns"] = (np.log(HengSeng["Adj Close"])).diff()
NASDAQ["NASDAQLogReturns"] = (np.log(NASDAQ["Adj Close"])).diff()
GermanDax100["GermanDax100LogReturns"] = (np.log(GermanDax100["Adj Close"])).diff()
Netherland25["Netherland25LogReturns"] = (np.log(Netherland25["Adj Close"])).diff()
Europe50["Europe50LogReturns"] = (np.log(Europe50["Adj Close"])).diff()

df = pd.DataFrame({
    'HengSeng': HengSeng["HengSengLogReturns"]
    'NASDAQ': NASDAQ["NASDAQLogReturns"]
    'GermanDax100': GermanDax100["GermanDax100LogReturns"]
    'Netherland25': Netherland25["Netherland25LogReturns"]
    'Europe50': Europe50["Europe50LogReturns"]
})

print(df.corr())
Related