Heatmaps
The wikipedia page features the Global Industry Classification Standard (GICS) structure of sectors and sub-industries. We will aggregate the data by:
- Sector, for a top-down view
- Sub-industry, for a bottom-up view
- Finally, sector and sub-industry, to pick winners and losers within each sector
We use the .groupby()
method and sort by score
. We then use the Styler constructor .style.background_gradient()
to paint the market by numbers:
groupby_cols = ['score'] + regime_cols
sort_key = ['GICS Sector']
regime_df.groupby(sort_key)[groupby_cols].mean().sort_values(
by= 'score').style.background_gradient(
subset= groupby_cols,cmap= 'RdYlGn').format('{:.1g}')
The heatmap covers all regime methodologies in both absolute and relative:
- score: lateral sum of all the methods at the stock level.
- rg: floor/ceiling regime in absolute.
- rrg: floor/ceiling regime in relative...