Nested Clustered: private API

PortfolioOptimisers.nested_clustered_td_defaultsFunction
nested_clustered_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}}}}}, opti::NoDefault, opto::NoDefault, wf::IterativeWeightFinaliser{Int64}}

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

Shared by the constructor's test-substitution pass and time_dependent_field_defaults. The optimiser-valued fields opti and opto are required and have no static default, so they are marked NoDefault: a schedule there must carry its own default to be usable outside a fold loop. pe, cle and wf reset to their keyword defaults; fields whose static default is nothing (wb, fees, sets, fb) are omitted.

Related

source
PortfolioOptimisers.reset_time_dependent_estimatorMethod
reset_time_dependent_estimator(
    opt::NestedClustered
) -> NestedClustered

Replace this meta-optimiser's own time-dependent fields with their static defaults.

Deliberately does not recurse into the wrapped optimisers: a standalone meta solve consumes inner per-fold schedules through its inner cross-validation leg, and its fold-less full-window inner solves reset themselves at their own _optimise seam. Only the meta's own fields (applied to the combined weights, resolved by an outer fold loop when one exists) are inert here. A bind = :nearest schedule in a field the meta hands across its own inner fold loop (see inner_fold_fields) is likewise left in place — resetting it here would replace it with its default before the inner cross-validation ever saw it.

source
PortfolioOptimisers.assert_rc_plMethod
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 on success; throws an ArgumentError otherwise.

Related

source
PortfolioOptimisers.stated_constraint_space_basisFunction
stated_constraint_space_basis(space::FactorSpace) -> Bool
stated_constraint_space_basis(ece::ExposureConstraintEstimator) -> Bool
stated_constraint_space_basis(lcse::AbstractVector) -> Bool
stated_constraint_space_basis(::Any) -> Bool

Report whether anything in an lcse slot carries a precomputed basis, so an outer optimiser can refuse it.

A stated basis is asset-indexed data written before the universe was known. An inner solve slices the universe, and port_opt_view slices the basis with it, so a stated basis is legal there. An outer solve replaces the universe with cluster names, and no slice of asset loadings follows that — so it must be refused, in the same shape as the refusals on opt.re and opt.rba.re.

The predicate is false for everything else, including a space whose re is an estimator: an estimator refits against whatever universe it is handed, which is exactly what makes it the remedy the message names.

Related

source
PortfolioOptimisers.assert_external_optimiserMethod
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

  • nothing on success; throws an ArgumentError otherwise.

Related

source
PortfolioOptimisers.assert_rc_varianceFunction
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 on success; throws an ArgumentError otherwise.

Related

source
PortfolioOptimisers._update_asset_setsFunction
_update_asset_sets(
    nco::NestedClustered,
    rdo::ReturnsResult
) -> Any

Align the outer optimiser's asset sets with the synthetic universe produced by the inner optimisations.

The outer optimiser of a NestedClustered does not see the original assets. It sees one synthetic asset per cluster, whose names are carried by the outer returns result rdo. An outer optimiser configured with UniverseSets built over the original universe would therefore resolve its constraints against the wrong names, so the sets are rebuilt over the cluster names before the outer solve.

Arguments

  • nco::NestedClustered: The nested clustered optimiser.
  • rdo::ReturnsResult: Outer returns result, whose nx holds the cluster names.

Returns

  • nco::NestedClustered: Instance with the outer optimiser's asset sets rebuilt over rdo.nx, or nco unchanged when it has no outer asset sets, or they already match.

Details

  • Handles both shapes of outer optimiser: one that nests its own optimiser (nco.opto.opt.sets) and one that carries the sets directly (nco.opto.sets).
  • The dictionary is copied before being reset, so the caller's UniverseSets is not mutated.

Related

source