-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCorrelation.py
56 lines (38 loc) · 1.69 KB
/
Correlation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 25 13:59:30 2018
@author: Matthew Dong
"""
import pandas as pd
### load data
excel_file = 'Absolute Momentum.xlsx'
EAFE = pd.read_excel(excel_file, sheet_name = 'MSCI')
EAFE = EAFE.set_index(['Date'])
EAFE_return= EAFE[["EAFE Return"]][12:480]
USA = pd.read_excel(excel_file, sheet_name = 'MSCI')
USA = USA.set_index(['Date'])
USA_return = USA[["USA Return"]][12:480]
TBOND = pd.read_excel(excel_file, sheet_name = 'Treasury')
TBOND = TBOND.set_index(['Date'])
TBOND_return= TBOND[["TBOND Return"]][12:480]
Credit = pd.read_excel(excel_file, sheet_name = 'US Government&Credit')
Credit = Credit.set_index(['Date'])
Credit_return= Credit[["Credit Return"]][12:480]
REIT = pd.read_excel(excel_file, sheet_name = 'REIT')
REIT = REIT.set_index(['Date'])
REIT_return = REIT[["REIT Return"]][12:480]
GSCI = pd.read_excel(excel_file, sheet_name = 'GSCI')
GSCI = GSCI.set_index(['Date'])
GSCI_return = GSCI[["GSCI Return"]][12:480]
Gold = pd.read_excel(excel_file, sheet_name = 'Gold')
Gold = Gold.set_index(['Date'])
Gold_return = Gold[["Gold Return"]][12:480]
HiYld = pd.read_excel(excel_file, sheet_name = 'US Corporate High Yield')
HiYld = HiYld.set_index(['Date'])
HiYld_return = HiYld[["HiYld Return"]][12:480]
assets = [EAFE_return, USA_return, TBOND_return, Credit_return, HiYld_return, REIT_return, GSCI_return, Gold_return]
assetnames = ["EAFE Return", "USA Return", "TBOND Return", "Credit Return", "HiYld Return", "REIT Return", "GSCI Return", "Gold Return"]
a = assets[1:]
anames = assetnames[1:]
for x in range(0,7):
print(str(anames[x]) + " " + str(EAFE_return["EAFE Return"].corr(a[x][anames[x]])))