Package 'HierPortfolios'

Title: Hierarchical Risk Clustering Portfolio Allocation Strategies
Description: Machine learning hierarchical risk clustering portfolio allocation strategies. The implemented methods are: Hierarchical risk parity (De Prado, 2016) <DOI: 10.3905/jpm.2016.42.4.059>. Hierarchical clustering-based asset allocation (Raffinot, 2017) <DOI: 10.3905/jpm.2018.44.2.089>. Hierarchical equal risk contribution portfolio (Raffinot, 2018) <DOI: 10.2139/ssrn.3237540>. A Constrained Hierarchical Risk Parity Algorithm with Cluster-based Capital Allocation (Pfitzingera and Katzke, 2019) <https://www.ekon.sun.ac.za/wpapers/2019/wp142019/wp142019.pdf>.
Authors: Carlos Trucios [aut, cre] , Moon Jun Kwon [aut], São Paulo Research Foundation (FAPESP), grant 2022/09122-0 [fnd], Programa de Incentivo a Novos Docentes da UNICAMP (PIND), grant 2525/23 [fnd]
Maintainer: Carlos Trucios <[email protected]>
License: GPL-2
Version: 1.0.1
Built: 2025-03-08 04:00:20 UTC
Source: https://github.com/ctruciosm/hierportfolios

Help Index


Daily returns (in percentage) of 15 assets.

Description

Dataset used to illustrate how to use the portfolio allocation strategies implemented in this package.


Constrained Hierarchical Risk Parity

Description

Performs the Constrained Hierarchical Risk Parity portfolio strategy proposed by Pfitzinger and Katzke (2019).

Usage

DHRP_Portfolio(covar, graph = FALSE, tau = 1, UB = NULL, LB = NULL)

Arguments

covar

Covariance matrix of returns. The covariance matrix will be transformed into correlation matrix and then into a distance matrix.

graph

To plot de dendrogram set this value to TRUE. By default this value is equal to FALSE.

tau

Parameter to evaluate asset similarity at the cluster edges. Default value is 1.

UB

Upper bound for weights. By default this value is equal to NULL

LB

Lower bound for weights. By default this value is equal to NULL

Value

portfolio weights

Author(s)

Carlos Trucios and Moon Jun Kwon

References

Pfitzinger, J., and Katzke, N. A constrained hierarchical risk parity algorithm with cluster-based capital allocation (2019). Working Paper.

See Also

HCAA_Portfolio, HRP_Portfolio and HERC_Portfolio

Examples

covar <- cov(mldp_returns)
DHRP_Portfolio(covar)

Hierarchical Clustering-Based Asset Allocation

Description

Performs the Hierarchical Clustering-Based Asset Allocation strategy proposed by Raffinot (2017). Several linkage methods for the hierarchical clustering can be used, by default the "ward" linkage is used. The numbers of clusters is selected using the Gap index of Tibshirani et al. (2001).

Usage

HCAA_Portfolio(covar, linkage = "ward", graph = FALSE, clusters = NULL)

Arguments

covar

Covariance matrix of returns. The covariance matrix will be transformed into correlation matrix and then into a distance matrix.

linkage

Linkage method used in the hierarchical clustering. Allowed options are "single", "complete", "average" or "ward". Default option is "ward".

graph

To plot de dendrogram set this value to TRUE. By default this value is equal to FALSE.

clusters

Numbers of clusters. If NULL (default), the gap index is applied.

Value

portfolio weights.

Author(s)

Carlos Trucios

References

Raffinot, Thomas. "Hierarchical clustering-based asset allocation." The Journal of Portfolio Management 44.2 (2017): 89-99.

Tibshirani, Robert, Guenther Walther, and Trevor Hastie. "Estimating the number of clusters in a data set via the gap statistic." Journal of the Royal Statistical Society: Series B (Statistical Methodology) 63.2 (2001): 411-423.

See Also

HRP_Portfolio, HERC_Portfolio and DHRP_Portfolio

Examples

covar <- cov(daily_returns)
HCAA_Portfolio(covar)

Hierarchical Equal Risk Contribution

Description

Performs the Hierarchical Equal Risk Contribution portfolio strategy proposed by Raffinot (2018). Several linkage methods for the hierarchical clustering can be used, by default the "ward" linkage is used. This function uses the variance as risk measure. The number of clusters is selected using the Gap index of Tibshirani et al. (2001). The implemenation follows Sjostrand and Nina (2020).

Usage

HERC_Portfolio(covar, linkage = "ward", graph = FALSE, clusters = NULL)

Arguments

covar

Covariance matrix of returns. The covariance matrix will be transformed into correlation matrix and then into a distance matrix.

linkage

Linkage method used in the hierarchical clustering. Allowed options are "single", "complete", "average" or "ward". Default option is "ward".

graph

To plot de dendrogram set this value to TRUE. By default this value is equal to FALSE.

clusters

Numbers of clusters. If NULL (default), the gap index is applied.

Value

portfolio weights.

Author(s)

Carlos Trucios and Moon Jun Kwon

References

Raffinot, Thomas. "The hierarchical equal risk contribution portfolio." Available at SSRN 3237540 (2018).

Tibshirani, Robert, Guenther Walther, and Trevor Hastie. "Estimating the number of clusters in a data set via the gap statistic." Journal of the Royal Statistical Society: Series B (Statistical Methodology) 63.2 (2001): 411-423.

See Also

HRP_Portfolio, HCAA_Portfolio and DHRP_Portfolio

Examples

covar <- cov(daily_returns)
HERC_Portfolio(covar)

Hierarchical Risk Parity

Description

Performs the Hierarchical Risk Parity portfolio proposed strategy by De Prado (2016). Several linkage methods for the hierarchical clustering can be used, by default the "single" linkage is used.

Usage

HRP_Portfolio(covar, linkage = "single", graph = FALSE)

Arguments

covar

Covariance matrix of returns. The covariance matrix will be transformed into correlation matrix and then into a distance matrix.

linkage

Linkage method used in the hierarchical clustering. Allowed options are "single", "complete", "average" or "ward". Default option is "single".

graph

To plot de dendrogram set this value to TRUE. By default this value is equal to FALSE.

Value

portfolio weights

Author(s)

Carlos Trucios

References

De Prado, Marcos Lopez. "Building diversified portfolios that outperform out of sample." The Journal of Portfolio Management 42.4 (2016): 59-69.

See Also

HCAA_Portfolio, HERC_Portfolio and DHRP_Portfolio

Examples

covar <- cov(mldp_returns)
HRP_Portfolio(covar)

Returns of 10 simulated assets.

Description

This dataset contains the simulated returns used in the numerical example of Marcos Lopez de Prado's paper, hence the name mldp_returns. The Python code used to reproduce this simulated data is kindly provided by the author in the supplementary material of his paper.

References

De Prado, Marcos Lopez. "Building diversified portfolios that outperform out of sample." The Journal of Portfolio Management 42.4 (2016): 59-69.