Fast Threshold Clustering Algorithm

The Fast Threshold Clustering Algorithm (FTCA) of Varadi (2013) is a greedy clustering on a codependence threshold that needs no number of clusters. Among the assets not yet clustered it takes the one with the highest average codependence H and the one with the lowest L. If H and L are codependent above the threshold, they form a cluster with every remaining asset whose average codependence with them is above it; otherwise H forms a cluster with the remaining assets above the threshold with H, and then L with those above it with L. This repeats until every asset belongs to a cluster.

The formula for the Fast Threshold Clustering Algorithm starts from the average codependence \(A_{i}\) of every asset i with the n assets not yet clustered, with \(C_{i , j}\) the codependence:

\[A_{i} = \frac{\sum_{j=1}^{n} C_{i,j}}{n}\]

When H and L are codependent above the threshold c, an asset a joins their cluster when its average codependence with the two exceeds c:

  • \[(C_{a , H} + C_{a , L}) / 2 > c\]

A high threshold gives many small clusters, a low one a few large ones. It is fast and transparent, but greedy: an asset can end up in the cluster of the first anchor it passes rather than the one it fits best.

Group the assets into clusters of assets that move together, the clusters that HERC and NCO allocate across.

Clustering groups the assets by how much they move together, on the distance of a codependence (see get_codependence_matrix), so that a portfolio can spread its risk across groups rather than across individual assets that partly duplicate each other. The methods differ in whether they need a number of clusters and in the shape of the groups they find.

Also known as: FTCA, threshold clustering.

In the Finance Toolkit this is get_asset_clusters with method="ftca", the same function as Asset Clusters.

Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_asset_clusters:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_asset_clusters(method="ftca")

Which returns:

Item Cluster
AAPL 1
MSFT 1
JNJ 2
XOM 3

References

  • Paper Varadi, D. (2013). “The Fast Threshold Clustering Algorithm (FTCA).” CSS Analytics.
  • Library Referenced against ffn’s calc_ftca (Fast Threshold Clustering Algorithm)
Share