Base clustering optimisation
PortfolioOptimisers.BaseClusteringOptimisationEstimator Type
abstract type BaseClusteringOptimisationEstimator <: BaseOptimisationEstimatorAbstract supertype for base clustering optimisation estimators.
These are intermediate configuration types used in hierarchical/clustering optimisation pipelines.
Related
sourcePortfolioOptimisers.ClusteringOptimisationEstimator Type
abstract type ClusteringOptimisationEstimator <: NonFiniteAllocationOptimisationEstimatorAbstract 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
PortfolioOptimisers.HierarchicalResult Type
struct HierarchicalResult{__T_oe, __T_pr, __T_clr, __T_wb, __T_fees, __T_retcode, __T_w, __T_fb} <: NonJuMPOptimisationResultResult type for hierarchical (clustering-based) portfolio optimisation.
Fields
oe: Type of the optimisation estimator that produced this result.pr: Prior result.clr: Clusters result.wb: Weight bounds.fees: Fees estimator or result.retcode: Optimisation return code.w: Portfolio weights vectorassets × 1.fb: Fallback result or estimator.
Related
sourcePortfolioOptimisers.factory Method
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
<:AbstractResult}, args...; kwargs...) -> aNo-op factory function for constructing objects with a uniform interface.
Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.
Arguments
a: Indicates no object should be constructed.args...: Arbitrary positional arguments (ignored).kwargs...: Arbitrary keyword arguments (ignored).
Returns
a: The input unchanged.
Examples
julia> factory(nothing, 1, 2; x = 3)
julia> factory(MeanValue())
MeanValue
w ┴ nothingRelated
sourcefactory(res::NonFiniteAllocationOptimisationResult, fb::Option{<:OptE_Opt})Rebuild a continuous optimisation result with an updated fallback optimiser fb.
Every optimisation result carries fb as its last field, so the generic rebuild copies all fields unchanged except the trailing fb. Concrete result types may override this method when rebuilding requires more than swapping fb.
Related
sourcefactory(
opt::Union{NonFiniteAllocationOptimisationEstimator, NonFiniteAllocationOptimisationResult},
_
) -> RandomWeighted{_A, var"#s179", _B, _C, _D, var"#s1791", _E, Bool} where {_A, var"#s179"<:AbstractRNG, _B, _C, _D, var"#s1791"<:WeightFinaliser, _E}Return opt unchanged.
Default pass-through factory for optimisation estimators and results. Overridden for estimators that carry parameters requiring update at each optimisation step.
Related
sourcePortfolioOptimisers.HierarchicalOptimiser Type
struct HierarchicalOptimiser{__T_pe, __T_cle, __T_slv, __T_wb, __T_fees, __T_sets, __T_wf, __T_brt, __T_cle_pr, __T_strict} <: BaseClusteringOptimisationEstimatorBase configuration for hierarchical clustering-based portfolio optimisers.
HierarchicalOptimiser combines a prior estimator, a clustering estimator, and weight bound/fee specifications to provide a reusable base configuration for hierarchical optimisers (HRP, HERC, SCHRP, etc.).
Fields
pe: Prior estimator.cle: Clusters estimator.slv: Solver or vector of solvers.wb: Weight bounds.fees: Fees estimator or result.sets: Sets used to map estimator values to features.wf: Weight finaliser.brt: Whether to use bootstrap returns.cle_pr: Whether to pass the prior result to the clustering estimator.strict: Whether to strictly enforce weight bounds.
Constructors
HierarchicalOptimiser(;
pe::PrE_Pr = EmpiricalPrior(),
cle::HClE_HCl = ClustersEstimator(),
slv::Option{<:Slv_VecSlv} = nothing,
wb::Option{<:WbE_Wb} = WeightBounds(),
fees::Option{<:FeesE_Fees} = nothing,
sets::Option{<:AssetSets} = nothing,
wf::WeightFinaliser = IterativeWeightFinaliser(),
brt::Bool = false,
cle_pr::Bool = true,
strict::Bool = false
) -> HierarchicalOptimiserKeywords correspond to the struct's fields.
Examples
julia> HierarchicalOptimiser()
HierarchicalOptimiser
pe ┼ EmpiricalPrior
│ ce ┼ PortfolioOptimisersCovariance
│ │ ce ┼ Covariance
│ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ w ┴ nothing
│ │ │ ce ┼ GeneralCovariance
│ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ w ┴ nothing
│ │ │ alg ┴ Full()
│ │ mp ┼ MatrixProcessing
│ │ │ pdm ┼ Posdef
│ │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ │ │ dn ┼ nothing
│ │ │ dt ┼ nothing
│ │ │ alg ┼ nothing
│ │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)
│ me ┼ SimpleExpectedReturns
│ │ w ┴ nothing
│ horizon ┴ nothing
cle ┼ ClustersEstimator
│ ce ┼ PortfolioOptimisersCovariance
│ │ ce ┼ Covariance
│ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ w ┴ nothing
│ │ │ ce ┼ GeneralCovariance
│ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ w ┴ nothing
│ │ │ alg ┴ Full()
│ │ mp ┼ MatrixProcessing
│ │ │ pdm ┼ Posdef
│ │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ │ │ dn ┼ nothing
│ │ │ dt ┼ nothing
│ │ │ alg ┼ nothing
│ │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)
│ de ┼ Distance
│ │ power ┼ nothing
│ │ alg ┴ CanonicalDistance()
│ alg ┼ HClustAlgorithm
│ │ linkage ┴ Symbol: :ward
│ onc ┼ OptimalNumberClusters
│ │ max_k ┼ nothing
│ │ alg ┼ SecondOrderDifference
│ │ │ alg ┼ StandardisedValue
│ │ │ │ mv ┼ MeanValue
│ │ │ │ │ w ┴ nothing
│ │ │ │ sv ┼ StdValue
│ │ │ │ │ w ┼ nothing
│ │ │ │ │ corrected ┴ Bool: true
slv ┼ nothing
wb ┼ WeightBounds
│ lb ┼ Float64: 0.0
│ ub ┴ Float64: 1.0
fees ┼ nothing
sets ┼ nothing
wf ┼ IterativeWeightFinaliser
│ iter ┴ Int64: 100
brt ┼ Bool: false
cle_pr ┼ Bool: true
strict ┴ Bool: falseRelated
PortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(opt::HierarchicalOptimiser) -> AnyReturn whether the HierarchicalOptimiser requires previous portfolio weights (based on fee structure).
Related
sourcePortfolioOptimisers.factory Method
factory(
opt::HierarchicalOptimiser,
w::AbstractVector
) -> HierarchicalOptimiser{_A, _B, _C, _D, _E, _F, <:WeightFinaliser, Bool, Bool, Bool} where {_A, _B, _C, _D, _E, _F}Create a HierarchicalOptimiser updating the fee structure with weights w.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
hco::HierarchicalOptimiser,
i,
args...
) -> HierarchicalOptimiser{_A, _B, _C, _D, _E, _F, <:WeightFinaliser, Bool, Bool, Bool} where {_A, _B, _C, _D, _E, _F}Return a view of HierarchicalOptimiser hco sliced to asset indices i.
Related
sourcePortfolioOptimisers.assert_internal_optimiser Method
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
nothingon success; throwsArgCheckerror otherwise.
Related
sourcePortfolioOptimisers.unitary_expected_risks Method
unitary_expected_risks(r, X, ...)Compute the expected risk for unitary (equal-weight) portfolios within each cluster.
Returns a vector of risk values, one per cluster, where each risk is computed for the equal-weight portfolio within that cluster.
Arguments
r: Risk measure.X: Asset return matrix.Additional cluster and weight parameters.
Returns
- Vector of expected risk values per cluster.
Related
sourcePortfolioOptimisers.unitary_expected_risks! Method
unitary_expected_risks!(wk, rk, r, ...)Compute and store the expected risk for each cluster's unitary portfolio in-place.
Fills rk with the expected risk for the equal-weight portfolio within each cluster, and wk with the corresponding weights.
Arguments
wk: Output weight vector (in-place).rk: Output risk vector (in-place).r: Risk measure.Additional cluster and weight parameters.
Returns
nothing(fillswkandrkin-place).
Related
source