PortfolioOptimiser.jl

Portfolio optimisation library.
Author dcelisgarza
Popularity
5 Stars
Updated Last
9 Months Ago
Started In
May 2022

PortfolioOptimiser

Category Badge
Docs Stable Dev
Examples Binder
CI Tests Documentation Aqua
Coverage Codecov Coveralls

Description

PortfolioOptimiser is a library for portfolio optimisation. It was written with composability and extensibility in mind. It offers a broad range of functionality out of the box. It wraps a lot of external functionality in types for dispatch purposes and to allow easy development and extensibility.

Parameter estimation

Matrix processing

These only apply to covariance, correlation, and cokurtosis estimators. Dissimilarity and similarity matrices use the results of correlation estimators, so they are indirectly used there.

Sparsification

  • Local/Global parsimonious estimator (LoGo), LoGo.

Fixing non-positive definite matrices

Denoising methods

Expected mean returns estimators

  • Simple mean, MuSimple.
  • James-Stein (JS), JS.
  • Bayes-Stein (BS), BS.
  • Bodnar-Okhrin-Parolya (BOP), BOP.

The JS, BS and BOP estimators also use a target for correcting their estimates.

  • Grand mean (GM), GM.
  • Volatility-weighted grand mean (VW), VW.
  • Mean square error of sample mean (SE), SE.

Covariance estimators

Correlation estimators

All covariance estimators can be used for correlation estimation.

Disimilarity/distance matrix functions

Triangulated maximally filtered graph similarity matrix functions

Bin width estimation functions

  • Knuth, require PyCall and astropy to be installed, Knuth.
  • Freedman, require PyCall and astropy to be installed, Freedman.
  • Scott, require PyCall and astropy to be installed, Scott.
  • Hacine-Gharbi and Ravier, HGR.

Cokurtosis estimators

Coskewness estimators

Clustering

  • Hierarchical clustering, HAC.
  • Direct Bubble Hierarchy Trees clustering, DBHT.

Determining number of clusters

Networks

  • Triangular maximally filtered graphs (TMFG), TMFG.
  • Minimum spanning tree (MST), MST.

Centrality measures

Minimum spanning tree algorithms

Worst case expected mean returns sets and covariance

Bootstrapping methods

Elliptical constraint error size estimation

Regression methods

Stepwise methods

  • Forward regression, FReg.
  • Backward regression, BReg.

Regression criteria

  • p-value threshold, PVal.

  • Model quality indicators.

    • Akaike's Information Criterion, AIC.
    • Corrected Akaike's Information Criterion for small sample sizes, AICC.
    • Bayesian Information Criterion, BIC.
    • Rยฒ of a linear model, RSq.
    • adjusted Rยฒ for a linear model, AdjRSq.

Dimensionality reduction

Black Litterman models

Black Litterman factor models

  • Augmented Black Litterman, ABLType.
  • Bayesian Black Litterman, BBLType.

Linear moments (L-moments)

  • Normalised constant relative risk aversion coefficients, CRRA.
  • Maximum entropy, MaxEntropy.
  • Minimum Sum of Squares, MinSumSq.
  • Minimum Square Distance, MinSqDist.

Portfolio optimisation

These types of optimisations act on instances of Portfolio.

Traditional, Trad

This type of optimisation is the traditional efficient frontier optimisation.

Classes, PortClass

  • Classic, Classic.
  • Factor model, FM.
  • Black Litterman, BL.
  • Black Litterman Factor model, BLFM.

Expected returns

  • Arithmetic returns, NoKelly.
  • Approximate logarithmic mean returns, AKelly.
  • Exact logarithmic mean returns, EKelly.

Objective functions

Constraints

  • Maximum expected risk constraints.
  • Minimum expected return constraint.
  • Linear weight constraints.
  • Connected asset centrality constraints.
  • Asset network constraints.
  • Leverage constraints.
  • Maximum number of assets constraint.
  • Minimum number of effective assets constraint.
  • Tracking error (weights or returns) constraint.
  • Turnover constraint.
  • Rebalancing penalty.

Risk measures

Dispersion

  • Full dispersion.

    • Standard deviation, SD.
    • Mean absolute deviation (MAD), MAD.
    • Square root kurtosis, Kurt.
    • Range, RG.
    • Conditional value at risk range (CVaR range), CVaRRG.
    • Tail Gini range, TGRG.
    • Gini mean difference (GMD), GMD.
    • Quadratic negative skewness, Skew.
    • Brownian distance variance (dVar), dVar.
  • Downside dispersion.

    • Semi standard deviation, SSD.
    • First lower partial moment (Omega ratio), FLPM.
    • Second lower partial moment (Sortino ratio), SLPM.
    • Square root semi kurtosis, SKurt.
    • Quadratic negative semi skewness, SSkew.

Downside

  • Worst case realisation (Minimax), WR.
  • Conditional value at risk (CVaR), CVaR.
  • Entropic value at risk (EVaR), EVaR.
  • Relativistic value at risk (RLVaR), RLVaR.
  • Tail Gini, TG.

Drawdown

  • Maximum drawdown (Calmar ratio) for uncompounded cumulative returns, MDD.
  • Average drawdown for uncompounded cumulative returns, ADD.
  • Ulcer index for uncompounded cumulative returns, UCI.
  • Conditional drawdown at risk for uncompounded cumulative returns (CDaR), CDaR.
  • Entropic drawdown at risk for uncompounded cumulative returns (EDaR), EDaR.
  • Relativistic drawdown at risk for uncompounded cumulative returns (RLDaR), RLDaR.

Linear moments (L-moments)

  • L-moment ordered weight array, OWA.

Worst case mean variance, WC

This type of optimisation requires worst case sets for the covariance and expected returns. The optimisation uses these sets to perform a mean variance optimisation.

Constraints

  • Maximum expected worst case standard deviation constraint.
  • Minimum expected worst case return constraint.
  • Linear weight constraints.
  • Connected asset centrality constraints.
  • Asset network constraints.
  • Leverage constraints.
  • Maximum number of assets constraint.
  • Minimum number of effective assets constraint.
  • Tracking error (weights or returns) constraint.
  • Turnover constraint.
  • Rebalancing penalty.

Risk parity, RP

This type of optimisation requires a risk budget per asset or factor. The optimisation attempts to minimise the difference between the risk budget and risk contribution of the asset or factor in the optimised portfolio.

Classes, PortClass

  • Classic, Classic.
  • Factor model, FM.
  • Factor risk contribution, FC.

Constraints

  • Minimum expected return constraint.
  • Linear weight constraints.

Risk measures

Dispersion

  • Full dispersion.

    • Standard deviation, SD.
    • Mean absolute deviation (MAD), MAD.
    • Square root kurtosis, Kurt.
    • Range, RG.
    • Conditional value at risk range (CVaR range), CVaRRG.
    • Tail Gini range, TGRG.
    • Gini mean difference (GMD), GMD.
    • Quadratic negative skewness, Skew.
    • Brownian distance variance (dVar), dVar.
  • Downside dispersion.

    • Semi standard deviation, SSD.
    • First lower partial moment (Omega ratio), FLPM.
    • Second lower partial moment (Sortino ratio), SLPM.
    • Square root semi kurtosis, SKurt.
    • Quadratic negative semi skewness, SSkew.

Downside

  • Worst case realisation (Minimax), WR.
  • Conditional value at risk (CVaR), CVaR.
  • Entropic value at risk (EVaR), EVaR.
  • Relativistic value at risk (RLVaR), RLVaR.
  • Tail Gini, TG.

Drawdown

  • Maximum drawdown (Calmar ratio) for uncompounded cumulative returns, MDD.
  • Average drawdown for uncompounded cumulative returns, ADD.
  • Ulcer index for uncompounded cumulative returns, UCI.
  • Conditional drawdown at risk for uncompounded cumulative returns (CDaR), CDaR.
  • Entropic drawdown at risk for uncompounded cumulative returns (EDaR), EDaR.
  • Relativistic drawdown at risk for uncompounded cumulative returns (RLDaR), RLDaR.

Linear moments (L-moments)

  • L-moment ordered weight array, OWA.

Relaxed risk parity mean variance, RRP

This type of optimisation requires a risk budget per asset. The optimisation attempts to minimise the difference between the risk budget and relaxed formulation of the standard deviation risk measure.

Classes, PortClass

Constraints

  • Minimum expected return constraint.
  • Linear weight constraints.

Near Optimal Centering, NOC

Near optimal centering utilise the weights of an optimised portfolio. It computes a region of near optimality using the bounds of the efficient frontier, the expected risk and return of the optimal portfolio, and a user-provided parameter. It then optimises for a portfolio that best describes the region. It provides more diversification and robustness than Trad and smooths out the weight transitions as the efficient frontier is traversed.

Classes, PortClass

  • Classic, Classic.
  • Factor model, FM.
  • Black Litterman, BL.
  • Black Litterman Factor model, BLFM.

Constraints

  • Minimum expected return constraint.
  • Linear weight constraints.

Classes, PortClass

  • Classic, Classic.
  • Factor model, FM.
  • Black Litterman, BL.
  • Black Litterman Factor model, BLFM.

Expected returns

  • Arithmetic returns, NoKelly.
  • Approximate logarithmic mean returns, AKelly.
  • Exact logarithmic mean returns, EKelly.

Constraints

  • Maximum expected risk constraints.
  • Minimum expected return constraint.

Risk measures

Dispersion

  • Full dispersion.

    • Standard deviation, SD.
    • Mean absolute deviation (MAD), MAD.
    • Square root kurtosis, Kurt.
    • Range, RG.
    • Conditional value at risk range (CVaR range), CVaRRG.
    • Tail Gini range, TGRG.
    • Gini mean difference (GMD), GMD.
    • Quadratic negative skewness, Skew.
    • Brownian distance variance (dVar), dVar.
  • Downside dispersion.

    • Semi standard deviation, SSD.
    • First lower partial moment (Omega ratio), FLPM.
    • Second lower partial moment (Sortino ratio), SLPM.
    • Square root semi kurtosis, SKurt.
    • Quadratic negative semi skewness, SSkew.

Downside

  • Worst case realisation (Minimax), WR.
  • Conditional value at risk (CVaR), CVaR.
  • Entropic value at risk (EVaR), EVaR.
  • Relativistic value at risk (RLVaR), RLVaR.
  • Tail Gini, TG.

Drawdown

  • Maximum drawdown (Calmar ratio) for uncompounded cumulative returns, MDD.
  • Average drawdown for uncompounded cumulative returns, ADD.
  • Ulcer index for uncompounded cumulative returns, UCI.
  • Conditional drawdown at risk for uncompounded cumulative returns (CDaR), CDaR.
  • Entropic drawdown at risk for uncompounded cumulative returns (EDaR), EDaR.
  • Relativistic drawdown at risk for uncompounded cumulative returns (RLDaR), RLDaR.

Linear moments (L-moments)

  • L-moment ordered weight array, OWA.

Hierarchical portfolio optimisation

These types of optimisations act on instances of HCPortfolio.

Hierarchical risk parity, HRP, and hierarchical equal risk parity, HERC

Hierarchical risk parity, HRP

Hierarchical risk parity optimisations use the hierarchical clustering of assets to assign risk contributions by iteratively splitting the dendrogram in half and assigning weights to each half according to the relative risk each half represents with respect to the other. It does this until it splits the dendrogram all the way down to single leaves.

Hierarchical equal risk parity, HERC

Hierarchical equal risk parity optimisations use the hierarchical clustering relationships between assets to assign risk contributions by splitting the dendrogram into k clusters. It starts with the full dendrogram and progressively cuts it into k-1 levels (since the comparison for each side belongs to the k-th level). At each step, it loops through the clusters and checks to which side of the sub-dendrogram the cluster belongs. It accumulates the risk of that cluster to the risk of the side it belongs to. The weights for the assets on each side of the dendrogram are assigned based on the relative (with respect to the other side) aggregate risk from all clusters belonging to it, these are the inter-cluster weights. It then computes the risk for each cluster, assigning weights to each asset according to the relative risk it represents with respect to other assets, these are the intra-cluster weights. It then elementwise multiplies both weights to get the final asset weights.

HERC can make use of two risk measure arguments, one for the intra-cluster and one for the inter-cluster risk calculation. They can take linear combinations of risk measures.

Constraints

  • Minimum and maximum weights per asset.

Risk measures

Dispersion

  • Full dispersion.

    • Variance, Variance.
    • Standard deviation, SD.
    • Mean absolute deviation (MAD), MAD.
    • Square root kurtosis, Kurt.
    • Range, RG.
    • Conditional value at risk range (CVaR range), CVaRRG.
    • Tail Gini range, TGRG.
    • Gini mean difference (GMD), GMD.
    • Quadratic negative skewness, Skew.
    • Brownian distance variance (dVar), dVar.
  • Downside dispersion.

    • Semi Variance, Variance.
    • Semi standard deviation, SSD.
    • First lower partial moment (Omega ratio), FLPM.
    • Second lower partial moment (Sortino ratio), SLPM.
    • Square root semi kurtosis, SKurt.
    • Quadratic negative semi skewness, SSkew.

Downside

  • Worst case realisation (Minimax), WR.
  • Value at risk (VaR), VaR.
  • Conditional value at risk (CVaR), CVaR.
  • Entropic value at risk (EVaR), EVaR.
  • Relativistic value at risk (RLVaR), RLVaR.
  • Tail Gini, TG.

Drawdown

  • Maximum drawdown (Calmar ratio) for uncompounded cumulative returns, MDD.
  • Average drawdown for uncompounded cumulative returns, ADD.
  • Ulcer index for uncompounded cumulative returns, UCI.
  • Drawdown at for uncompounded cumulative returns risk (DaR), DaR.
  • Conditional drawdown at risk for uncompounded cumulative returns (CDaR), CDaR.
  • Entropic drawdown at risk for uncompounded cumulative returns (EDaR), EDaR.
  • Relativistic drawdown at risk for uncompounded cumulative returns (RLDaR), RLDaR.
  • Maximum drawdown (Calmar ratio) for compounded cumulative returns, MDD_r.
  • Average drawdown for compounded cumulative returns, ADD_r.
  • Ulcer index for compounded cumulative returns, UCI_r.
  • Drawdown at for compounded cumulative returns risk (DaR), DaR_r.
  • Conditional drawdown at risk for compounded cumulative returns (CDaR), CDaR_r.
  • Entropic drawdown at risk for compounded cumulative returns (EDaR), EDaR_r.
  • Relativistic drawdown at risk for compounded cumulative returns (RLDaR), RLDaR_r.

Linear moments (L-moments)

  • L-moment ordered weight array, OWA.

Nested clustered optimisation, NCO

Nested clustered optimisation combines the ideas of hierarchical equal risk parity optimisations and portfolio optimisations. They use the hierarchical clustering relationships between assets and splitting the dendrogram into k clusters. It then treats each cluster as its own isntance of Portfolio which is optimised in the usual way. The weights of each cluster are saved in a matrix, these are the intra-cluster weights. Then each cluster as a whole is treated as a synthetic asset, it statistics are internally computed from the fields in the NCO type. An instance of Portfolio is created from these synthetic assets and then optimised, these are the inter-cluster weights. The inter-cluster and intra-cluster weights are multiplied to give the asset weights.

NCO can make use of two risk measure arguments, one for the intra-cluster and one for the inter-cluster risk calculation. They can take linear combinations of risk measures.

Sub-types

NCO can take keyword arguments that define the supported by optimisations of Portfolio. Since there are intra- and inter-cluster optimisations, it can take individual arguments for both. This means it can perform any combination of Portfolio optimisations, except for WC.

NCO-Trad, NCO-NOC-Trad

Objective functions
Constraints

When applied to the intra-cluster optimisation the same constraint will be applied to all every cluster.

  • Maximum expected risk constraints.
  • Minimum expected return constraint.
  • Leverage constraints.

NCO-RP, NCO-RRP, NCO-NOC-RP, NCO-NOC-RRP

Constraints

When applied to the intra-cluster optimisation the same constraint will be applied to all every cluster.

  • Minimum expected return constraint.