Skip to content
All library documents

Using Clustering to Explore Market Regimes and Asset Relationships

Article Quant Q&A · Author: Richi Wa

Summary

The document considers clustering methods such as k-means and k-medoids in quantitative finance. Its concrete proposed use is to identify market regimes in which relationships between assets may differ. For example, a strategy based on gold hedging equity downturns could be made conditional on clusters that distinguish different market environments. The accompanying toy example clusters observations for two assets and plots their price levels by assigned group, with fitted curves to help visualize the patterns.

The example illustrates an exploratory use, not evidence that clustering improves a trading strategy or reliably detects regime changes. It supplies no out-of-sample evaluation, comparison with alternative methods, or guidance on feature scaling, cluster selection, or avoiding look-ahead bias. The cited resources are mentioned but not discussed in depth. A practitioner would need to choose suitable inputs and validate whether clusters are stable and useful for decisions.

Key ideas

  • Clustering can be explored as a way to separate market regimes.
  • Regime labels may help test whether cross-asset relationships change across environments.
  • The example groups paired asset observations and visualizes the resulting clusters.
  • The illustration does not establish that the clusters produce predictive or profitable signals.
  • Feature choices and out-of-sample validation are left unspecified.

Tags

Full text
# Which are useful applications of clustering in quantitative finance?


# Which are useful applications of clustering in quantitative finance?












Several machine learning algorithms have been applied in finance/trading. Focusing on clustering (k-means, k-medoids) what are useful and successful applications in quantitative finance? What is used by practitioners? Are there references or reports available?

EDIT: After those very good remarks and answers I wanted to insert this link where clustering and the development of clusters of asset classes (gold, stocks, bonds and much more) is presented.

## Answer by Jacob Amos (score 8, accepted)

https://quant.stackexchange.com/a/24700

One potential use I could imagine would be identifying paradigm shifts / regime change. Just as a quick toy example, maybe you're interested in how gold is often considered a hedge against downturns in the stock market. Say you are building a trading strategy based on that intuition, but want your model to be more flexible by identifying different regimes for which different approaches might work better. Clustering methods might help in that analysis. Here's a quick example of how one might visualize that type of thing.

I also found a few resources on the web after a quick search that you might find interesting.

- Dynamical analysis of clustering on financial market data

- Cluster Analysis for Evaluating Trading Strategies

- Survey of Deep Learning Techniques Applied to Trading (more general ML but still a good read)

R code used to make the plot:

```
library(Quandl)
syms = c(SP500="YAHOO/INDEX_GSPC.4", Gold="CHRIS/CME_GC1.6")
nmeans = 3
prices = na.omit(Quandl(syms, type='xts'))
df = as.data.frame(prices)
clusters = kmeans(df, centers=nmeans)$cluster
par(mar=c(2.5,2.5,0.5,0.5), mgp=c(1.5,0.5,0), family='mono', cex=0.7)
x = as.numeric(prices[,1])
y = as.numeric(prices[,2])
plot(x, y, pch=-1, xlab=names(syms)[1], ylab=names(syms)[2])
for (i in 1:nmeans){
    xx = df[clusters==i,1]
    yy = df[clusters==i,2]
    points(xx, yy, pch=19, col=rgb(t(col2rgb(i)/255), alpha=0.2))
    f = lm(yy~poly(xx, 3))
    lines(x=xx, y=predict.lm(f, data.frame(x=xx)), col=i, lwd=2)
}
grid(lty=1, col=rgb(0,0,0,0.2))
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.