Skip to content

Blog / Financial Models & Research

Portfolio Diversification: Identifying Stocks That Move Together

Holding five different stocks does not necessarily mean a portfolio is diversified. If all five companies respond similarly to market conditions, the portfolio may still have considerable concentration risk.

Sector classification is one way to understand this exposure, but I was interested in seeing whether stocks could be grouped based entirely on their return behaviour, without telling the model which sector each stock belongs to.

Portfolio Diversification: Identifying Stocks That Move Together

I used hierarchical clustering in Python to explore this. The experiment consisted of 40 synthetic stocks across five sectors: Banking, IT, Pharma, Auto and FMCG, with eight stocks in each sector and 750 daily return observations.

I used the first 500 observations to calculate the correlation between stocks and converted these correlations into a distance measure for clustering. Stocks with similar return patterns would have a smaller distance between them.

Instead of fixing the number of groups, I tested between two and eight clusters and used the silhouette score to select the number of groups. Five clusters produced the highest score, and all 40 stocks were grouped according to their original synthetic sectors, even though sector information was not supplied to the clustering model.

The next part was to understand whether these groups could be useful for portfolio diversification.

I generated 2,000 randomly selected portfolios for each of two approaches. In the first approach, all five stocks came from the same cluster. In the second, one stock was selected from each of the five clusters. Portfolio volatility was calculated using the remaining 250 daily observations, which were not used during clustering.

The average annualised volatility was 21.8% for portfolios holding stocks from the same cluster and 18.5% for portfolios holding stocks across different clusters. This represents a relative reduction of approximately 15%.

What I find useful about correlation-based clustering is that it provides another way to look at portfolio concentration. Two companies may belong to different sectors but still have similar exposure to interest rates, currency movements or broader economic conditions.

There are limitations to this experiment. The synthetic returns were generated using common market factors and sector-specific factors, so some of the relationships identified by the model were already built into the data. Also, correlations between stocks can change over time, particularly during periods of market stress.

It would be interesting to repeat this using actual NSE stock returns, review how the clusters change over different periods and compare the results with conventional sector-based diversification.

This is a personal experiment around portfolio risk, statistical modelling and machine learning, not an investment recommendation.