Relative rotation is an interesting approach to see what is hot and what is not.
The JdK RS-Ratios can be calculated for the S&P 500 index.
So what is leading? Tech. What is weakening? Real estate. Healthcare is in the bottom left quadrant.
The Python code?
def rs_ratio(prices_df, benchmark, window=10): from numpy import mean, std for series in prices_df: rs = (prices_df[series].divide(benchmark)) * 100 rs_ratio = rs.rolling(window).mean() rel_ratio = 100 + ((rs_ratio - rs_ratio.mean()) / rs_ratio.std() + 1) prices_df[series] = rel_ratio prices_df.dropna(axis=0, how='all', inplace=True) return prices_df