I'm looking for some direction on the proper way to cluster forward commodity curves based on their day over day returns.

I've worked on clustering in the past but I only dealt with spot prices rather than a full forward curve. For instance I would want to try and which forward curves move similarly across the full length of the curve rather than treat each forward month as a standalone price. Here's a simple example on the data in case I'm not describing it well:

Date Curve Name Forward Month Price
08/03/2022 Curve 1 1 1.10
08/03/2022 Curve 1 2 1.20
08/03/2022 Curve 1 3 1.15
08/03/2022 Curve 2 1 2.50
08/03/2022 Curve 2 2 2.30
08/03/2022 Curve 2 3 2.25
08/03/2022 Curve 3 1 5.30
08/03/2022 Curve 3 2 5.60
08/03/2022 Curve 3 3 5.55
08/02/2022 Curve 1 1 1.40
08/02/2022 Curve 1 2 1.60
08/02/2022 Curve 1 3 1.65
08/02/2022 Curve 2 1 2.40
08/02/2022 Curve 2 2 2.60
08/02/2022 Curve 2 3 2.85
08/02/2022 Curve 3 1 5.10
08/02/2022 Curve 3 2 5.40
08/02/2022 Curve 3 3 5.95

2 Answers 2


I believe the major difficulty here is defining the features, while the clustering is pretty standard.

Do you want the real values to match? Then cluster on the value directly.

Do you think the meaning lies in the difference over time? Then define your features as $P_t-P_0$

Do you think the features shuold be the change in percentage over time? Then define your features as $\frac{P_t-P_0}{P_0}$

Another way would be to model the time series with some model equation, for example with autoregression and use the coefficients as a measure of similarity.

The real question here is what do you define as similar curves, and if you don't know the answer then no clustering algorithm will find what you're looking for.


Reformat the data into a matrix, with rows corresponding to measurements for (curve $c$), and columns corresponding to (date $t$, forward-month $f$).

Log price return ("day over day return") for contract $c$ on date $t$ for forward-month $f$ is: $$r_{c,(t,f)} = \log\left(\frac{P_{c,(t,f)}}{P_{c,(t-1,f)}}\right)$$

Decompose your matrix with SVD (singular value decomposition, $X=UDV^\textrm{T}$). Then cluster the $K$ row-$i$ coefficients $U_{i,1}, U_{i,2}, \ldots U_{i,K} $, the first few coefficients of row $i$ on $K$ characteristic time-series in $V^\textrm{T}$, (a decomposition of common movements across rows).

For discussion of SVD, see widely available PDF of Wall, Michael E., Andreas Rechtsteiner, and Luis M. Rocha. "Singular value decomposition and principal component analysis." A practical approach to microarray data analysis. Springer, Boston, MA, 2003. 91-109.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.