Nested Clustered
PortfolioOptimisers.NestedClusteredResult Type
struct NestedClusteredResult{__T_oe, __T_pr, __T_clr, __T_wb, __T_fees, __T_resi, __T_reso, __T_cv, __T_retcode, __T_w, __T_fb} <: NonJuMPOptimisationResultResult type for Nested Clustered 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.resi: Inner optimisation results.reso: Outer optimisation results.cv: Cross-validation estimator.retcode: Optimisation return code.w: Final aggregated portfolio weights.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.NestedClustered Type
struct NestedClustered{__T_pe, __T_cle, __T_wb, __T_fees, __T_sets, __T_opti, __T_opto, __T_cv, __T_wf, __T_ex, __T_fb, __T_brt, __T_cle_pr, __T_strict} <: ClusteringOptimisationEstimatorNested Clustered Optimisation (NCO) portfolio optimiser.
NestedClustered implements the Nested Clustered Optimisation algorithm. It first clusters assets, then solves a within-cluster (inner) optimisation for each cluster independently, and finally solves an across-cluster (outer) optimisation to combine the cluster portfolios into a final portfolio.
Fields
pe: Prior estimator.cle: Clusters estimator.wb: Weight bounds estimator or weight bounds.fees: Fees estimator.sets: Sets used to map estimator values to features.opti: Inner optimiser.opto: Outer optimiser.cv: Cross-validation estimator.wf: Weight finaliser.ex: Parallel execution strategy.fb: Fallback result or estimator.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
NestedClustered(;
pe::PrE_Pr = EmpiricalPrior(),
cle::ClE_Cl = ClustersEstimator(),
wb::Option{<:WbE_Wb} = WeightBounds(),
fees::Option{<:FeesE_Fees} = nothing,
sets::Option{<:AssetSets} = nothing,
opti::NonFiniteAllocationOptimisationEstimator,
opto::NonFiniteAllocationOptimisationEstimator = opti,
cv::Option{<:OptimisationCrossValidation} = nothing,
wf::WeightFinaliser = IterativeWeightFinaliser(),
ex::FLoops.Transducers.Executor = FLoops.ThreadedEx(),
fb::Option{<:OptE_Opt} = nothing,
brt::Bool = false,
cle_pr::Bool = true,
strict::Bool = false
) -> NestedClusteredKeywords correspond to the struct's fields.
Validation
optomust passassert_external_optimiserandassert_special_nco_requirements.If
opti !== opto:optimust passassert_internal_optimiserandassert_special_nco_requirements.If
cvis provided:optimust also passassert_external_optimiserandassert_special_nco_requirements.
Mathematical definition
Let clusters
Inner: for each cluster
, solve (sub-portfolio weights within ). Outer: form a
synthetic returns matrix from cluster portfolios and solve (allocation across clusters). Combine:
for .
Related
sourcePortfolioOptimisers.factory Method
factory(
nco::NestedClustered,
w::AbstractVector
) -> NestedClustered{_A, _B, _C, _D, _E, var"#s179", var"#s1791", _F, var"#s1792", var"#s1793", _G, Bool, Bool, Bool} where {_A, _B, _C, _D, _E, var"#s179"<:NonFiniteAllocationOptimisationEstimator, var"#s1791"<:NonFiniteAllocationOptimisationEstimator, _F, var"#s1792"<:WeightFinaliser, var"#s1793"<:Transducers.Executor, _G}Build an updated NestedClustered with all estimators that track previous weights updated via factory using w.
PortfolioOptimisers.port_opt_view Method
port_opt_view(
nco::NestedClustered,
i,
X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
args...
) -> NestedClustered{_A, _B, _C, _D, _E, var"#s179", var"#s1791", _F, var"#s1792", var"#s1793", _G, Bool, Bool, Bool} where {_A, _B, _C, _D, _E, var"#s179"<:NonFiniteAllocationOptimisationEstimator, var"#s1791"<:NonFiniteAllocationOptimisationEstimator, _F, var"#s1792"<:WeightFinaliser, var"#s1793"<:Transducers.Executor, _G}Return a cluster-sliced copy of NestedClustered for asset index set i and returns matrix X.
PortfolioOptimisers.predict_outer_nco_estimator_returns Function
predict_outer_nco_estimator_returns(
nco::NestedClustered,
rd::ReturnsResult,
pr::AbstractPriorResult,
fees::Option{<:Fees},
wi::MatNum,
resi::VecOpt,
cls::VecVecInt
)Predict outer portfolio returns for NestedClustered optimisation. Overload this using nco.cv for custom cross-validation prediction.
PortfolioOptimisers.optimise Method
optimise(nco::NestedClustered{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:Any, Nothing
}, rd::ReturnsResult;
dims::Int = 1, branchorder::Symbol = :optimal, str_names::Bool = false,
save::Bool = true, kwargs...) -> NestedClusteredResultRun the Nested Clustered Optimisation portfolio optimisation.
Arguments
nco: The nested clustered optimiser to use.rd: The returns result to use.dims: The dimension along which observations advance in time.branchorder: Passed to the inner and outer optimisers. If this optimiser uses hierarchical clustering, this applies to the clusterisation. The branch order to use for the clusterisation.str_names: Passed to the inner and outer optimisers. Whether to use string names for the assets in the optimisation.save: Passed to the inner and outer optimisers. Whether to save the JuMP model in the optimisation result.kwargs: Additional keyword arguments passed to the optimisation function.
Related
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(opt::NestedClustered) -> AnyReturn true if any sub-estimator of opt requires previous portfolio weights (fees, inner optimiser, outer optimiser, or fallback).
PortfolioOptimisers.assert_rc_pl Method
assert_rc_pl(opt)Assert that the optimiser does not use phylogeny risk contribution for NCO outer optimisation.
Checks that factor risk contribution optimisers do not use phylogeny-based constraints when used as the outer optimiser in NCO.
Arguments
opt: Optimisation estimator.
Returns
nothing.
Related
sourcePortfolioOptimisers.assert_external_optimiser Method
assert_external_optimiser(opt)Assert that the outer optimiser is valid for use in NCO.
Checks that the outer optimiser does not use pre-computed prior results, regression results, or unsupported variance/phylogeny risk contribution configurations.
Arguments
opt: Outer optimisation estimator.
Returns
nothingon success; throwsArgCheckerror otherwise.
Related
sourcePortfolioOptimisers.RiskBudgetingOptimiser Type
const RiskBudgetingOptimiser = Union{<:RiskBudgeting, <:RelaxedRiskBudgeting}Alias for risk budgeting JuMP optimisers.
Matches either RiskBudgeting or RelaxedRiskBudgeting. Used for dispatch in NCO validation and constraint generation.
Related
sourcePortfolioOptimisers.assert_rc_variance Function
assert_rc_variance(opt)Assert that the optimiser does not use variance risk contribution for NCO outer optimisation.
Checks that risk budgeting-based JuMP optimisers do not use variance for risk contribution when used as the outer optimiser in NCO.
Arguments
opt: Optimisation estimator.
Returns
nothing.
Related
source