Base clustering optimisation: private API

PortfolioOptimisers.ClusteringOptimisationEstimatorType
abstract type ClusteringOptimisationEstimator <: NonFiniteAllocationOptimisationEstimator

Abstract supertype for clustering-based portfolio optimisation estimators.

Clustering optimisation estimators use asset clustering to decompose the portfolio optimisation problem. Subtypes include HRP, HERC, and SCHRP.

Related

source
PortfolioOptimisers.assert_clustering_universeFunction
assert_clustering_universe(
    clr::AbstractClusteringResult,
    N::Integer
)

Assert that a clustering covers exactly the universe the optimisation is about to allocate over.

clusterise returns a fitted AbstractClusteringResult unchanged, so a caller who states one instead of an estimator states the leaf order as well. Nothing slices that order. Under an Investable Mask, or inside a subset or a nested view, the universe below the call is narrower than the one the caller clustered, and the leaf order would index the wrong columns. The weights would still come back, and they would be wrong, so the mismatch is refused where it is first visible.

A fixed clustering under a changing universe is stated as a ClustersEstimator, which refits per window and always matches.

Algorithm

  1. Read one cluster label per asset with assignments.
  2. Throw a DimensionMismatch when their count is not N.

Arguments

  • clr: Clustering result, fitted or just built.
  • N: Number of assets the optimisation runs on, after the reduction.

Validation

  • The clustering must carry one label per asset of the reduced universe.

Returns

  • nothing.

Related

source
PortfolioOptimisers.hierarchical_optimiser_td_defaultsFunction
hierarchical_optimiser_td_defaults(

) -> @NamedTuple{pe::EmpiricalPrior{PortfolioOptimisersCovariance{Covariance{SimpleExpectedReturns{Nothing, Nothing, Nothing}, GeneralCovariance{SimpleCovariance, Nothing, Nothing}, FullMoment, Nothing, Nothing, Nothing}, MatrixProcessing{Posdef{UnionAll, @NamedTuple{}}, Nothing, Nothing, Nothing, NTuple{4, Symbol}}, Nothing}, SimpleExpectedReturns{Nothing, Nothing, Nothing}, Nothing, Nothing, Nothing, Nothing}, cle::ClustersEstimator{PortfolioOptimisersCovariance{Covariance{SimpleExpectedReturns{Nothing, Nothing, Nothing}, GeneralCovariance{SimpleCovariance, Nothing, Nothing}, FullMoment, Nothing, Nothing, Nothing}, MatrixProcessing{Posdef{UnionAll, @NamedTuple{}}, Nothing, Nothing, Nothing, NTuple{4, Symbol}}, Nothing}, Distance{Nothing, CanonicalDistance}, HClustAlgorithm{Symbol}, OptimalNumberClusters{Nothing, SecondOrderDifference{StandardisedValue{MeanValue{Nothing}, StdValue{Nothing, Bool}}}}}, wb::WeightBounds{Float64, Float64}, wf::IterativeWeightFinaliser{Int64}}

Return the static defaults of the HierarchicalOptimiser fields that may hold a TimeDependent.

Shared by the constructor's test-substitution pass and time_dependent_field_defaults, so the fold-less value of a field is declared once. Fields whose static default is nothing are omitted.

Related

source
PortfolioOptimisers.assert_internal_optimiserMethod
assert_internal_optimiser(opt)

Assert that the inner (cluster-level) optimiser is valid for use in NCO.

Checks that the inner optimiser does not use pre-computed prior results or regression results, since these must be re-estimated for each cluster during NCO.

Arguments

  • opt: Inner optimisation estimator.

Returns

  • nothing on success; throws an ArgumentError otherwise.

Related

source
PortfolioOptimisers.unitary_expected_risksMethod
unitary_expected_risks(r::OptimisationRiskMeasure, X::MatNum,
                       fees::Option{<:Fees} = nothing) -> Vector

Compute the expected risk of each asset held alone.

The $i$-th entry is the risk of the portfolio whose weight vector is one in position $i$ and zero everywhere else, so the result has one entry per asset, not per cluster. For Variance the vector is the diagonal of the covariance matrix. The hierarchical optimisers invert this vector to build a naive risk parity allocation inside a cluster.

Arguments

  • r: Risk measure, already resolved by factory.
  • X: Asset return matrix, observations by assets.
  • fees: Fees to charge against each unit portfolio, or nothing.

Returns

  • rk::Vector: Expected risk of each asset held alone, of length size(X, 2).

Related

source
PortfolioOptimisers.unitary_expected_risks!Method
unitary_expected_risks!(wk::VecNum, rk::VecNum, r::OptimisationRiskMeasure,
                        X::MatNum, fees::Option{<:Fees} = nothing) -> Nothing

Write the expected risk of each asset held alone into rk.

The in-place form of unitary_expected_risks, for a caller that reuses one buffer across several risk measures.

Arguments

  • wk: Scratch weight vector, of length size(X, 2). It must arrive all zero, and it leaves all zero: each iteration raises one entry to one and lowers it again.
  • rk: Output risk vector, of length size(X, 2). It is overwritten in full.
  • r: Risk measure, already resolved by factory.
  • X: Asset return matrix, observations by assets.
  • fees: Fees to charge against each unit portfolio, or nothing.

Returns

  • nothing. The result is rk.

Related

source