Squared Angular Codependence

The Squared Angular Codependence is the squared Pearson correlation of the covariance estimate, the share of the variance of one asset that the other explains, the same construction as the Absolute Angular Codependence on the squared correlation (López de Prado, 2020, chapter 3).

The formula for the Squared Angular Codependence and its distance \(d_{i , j}\) is as follows:

\[c_{i,j} = \rho_{i,j}^{2}\] \[d_{i,j} = \sqrt{1 - \rho_{i,j}^{2}}\]

Where \(\rho_{i , j}\) is the Pearson correlation of the covariance estimate. Like the Absolute Angular Codependence it puts strongly negatively correlated assets close together, and it pushes weakly correlated assets further apart.

It is the codependence that the hierarchical optimizers (HRP, HERC, NCO) and get_asset_clusters take, or the distance they cluster on. Hierarchical portfolio construction groups the assets by how much they move together and spreads the capital across the groups, so the codependence decides which assets end up together. The Pearson correlation captures only linear co-movement on average; the other codependences capture co-movement in ranks, in large moves only, in any form of dependence or in crashes. Each comes with a distance, zero for assets that move as one, that the clustering works on (Mantegna, 1999).

Also known as: squared angular distance.

In the Finance Toolkit this is get_codependence_matrix with method="squared_angular", the same function as Codependence Matrix.

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

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

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_codependence_matrix(method="squared_angular")

Which returns:

References

  • Paper López de Prado, M. (2020). “Machine Learning for Asset Managers.” Cambridge University Press, chapters 2 and 3.
Share