Skip to content

Commit

Permalink
Update notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobortolan committed Aug 11, 2024
1 parent 15f0248 commit 6351601
Show file tree
Hide file tree
Showing 4 changed files with 13,302 additions and 1,805 deletions.
13 changes: 7 additions & 6 deletions case1.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@

correlation_matrix_avg = pd.DataFrame()

for year in range(1993, 2018, 5):
returns_sub = returns[returns['Year'].between(year, year+4)]
time_delta = 1
for year in range(1993, 2018, time_delta):
returns_sub = returns[returns['Year'].between(year, year+time_delta)]
correlation_matrix = returns_sub.drop(columns=['Date', 'Year']).corr()
correlation_matrix_avg[f'{year}-{year + 4}'] = correlation_matrix.mean()
correlation_matrix_avg[f'{year}-{year + time_delta}'] = correlation_matrix.mean()

fig = px.imshow(correlation_matrix, text_auto=True, title=f'Correlation Matrix ({year}-{year + 4})', color_continuous_scale='RdBu_r')
# fig.show()
fig = px.imshow(correlation_matrix, text_auto=True, title=f'Correlation Matrix ({year}-{year + time_delta})', color_continuous_scale='RdBu_r', zmin=0, zmax=1)
fig.show()

fig = px.imshow(correlation_matrix_avg, text_auto=True, title='Average correlation over sub-periods', color_continuous_scale='RdBu_r')
fig = px.imshow(correlation_matrix_avg, text_auto=True, title='Average correlation over sub-periods', color_continuous_scale='RdBu_r', zmin=0, zmax=1)
# fig.show()
Loading

0 comments on commit 6351601

Please sign in to comment.