Near optimal centering
PortfolioOptimisers.NearOptimalCenteringAlgorithm Type
abstract type NearOptimalCenteringAlgorithm <: OptimisationAlgorithmAbstract supertype for Near Optimal Centering algorithm variants.
Related Types
sourcePortfolioOptimisers.ConstrainedNearOptimalCentering Type
struct ConstrainedNearOptimalCentering <: NearOptimalCenteringAlgorithmConstrained Near Optimal Centering algorithm.
Applies Near Optimal Centering within the feasible region defined by the portfolio constraints.
Related Types
sourcePortfolioOptimisers.UnconstrainedNearOptimalCentering Type
struct UnconstrainedNearOptimalCentering <: NearOptimalCenteringAlgorithmUnconstrained Near Optimal Centering algorithm.
Applies Near Optimal Centering ignoring feasibility constraints (weights may temporarily violate bounds).
Related Types
sourcePortfolioOptimisers.NearOptimalCenteringResult Type
struct NearOptimalCenteringResult{__T_jr, __T_w_min_retcode, __T_w_opt_retcode, __T_w_max_retcode, __T_noc_retcode, __T_fb} <: RiskJuMPOptimisationResultResult type for Near Optimal Centering portfolio optimisation.
Fields
jr: Shared JuMP result core, seeJuMPOptimisationResult.w_min_retcode: Return code for the minimum-risk sub-problem.w_opt_retcode: Return code for the optimal-objective sub-problem.w_max_retcode: Return code for the maximum-risk sub-problem.noc_retcode: Return code for the near-optimal centering sub-problem.fb: Fallback result or estimator.
Property access delegates to the embedded JuMPOptimisationResult: the unique retcodes resolve directly, the virtual :w and unknown properties resolve through jr.
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
sourceBase.getproperty Method
getproperty(
r::RiskJuMPOptimisationResult,
sym::Symbol
) -> AnyDefault property access for RiskJuMPOptimisationResult: unique fields resolve directly; everything else delegates to the embedded JuMPOptimisationResult jr.
PortfolioOptimisers.NearOptimalSetup Type
struct NearOptimalSetup{__T_w_opt, __T_rk_opt, __T_rt_opt, __T_rt_min, __T_rt_max, __T_w_min, __T_w_max, __T_r, __T_opt, __T_attrs, __T_w_min_retcode, __T_w_opt_retcode, __T_w_max_retcode} <: AbstractResultIntermediate result type storing the setup data for Near Optimal Centering.
Holds pre-computed portfolio weights, risk and return targets, and sub-problem return codes needed to formulate and solve the NOC optimisation problem.
Fields
w_opt: Optimal portfolio weights.rk_opt: Optimal risk target.rt_opt: Optimal return target.rt_min: Minimum return target.rt_max: Maximum return target.w_min: Minimum risk portfolio weights.w_max: Maximum return portfolio weights.r: Risk measure or vector of risk measures.opt:JuMPoptimiser configuration.attrs: Processed JuMP optimiser attributes for the model-assembly pipeline.w_min_retcode: Return code for the minimum-risk sub-problem.w_opt_retcode: Return code for the optimal-objective sub-problem.w_max_retcode: Return code for the maximum-risk sub-problem.
Related
sourcePortfolioOptimisers.NearOptimalCentering Type
struct NearOptimalCentering{__T_opt, __T_r, __T_obj, __T_bins, __T_w_min, __T_w_min_ini, __T_w_opt, __T_w_opt_ini, __T_w_max, __T_w_max_ini, __T_ucs_flag, __T_alg, __T_fb} <: RiskJuMPOptimisationEstimatorNear Optimal Centering (NOC) portfolio optimiser.
NearOptimalCentering finds a portfolio that is centrally located within the region of near-optimal solutions. It first solves the minimum-risk, maximum-risk, and user-specified optimal-objective sub-problems, then maximises the minimum distance to the efficient frontier boundaries, yielding a portfolio that is robust to small perturbations in risk-return space.
Fields
opt:JuMPoptimiser configuration.r: Risk measure or vector of risk measures.obj: Portfolio objective function.bins: Number of equally-spaced risk bins for the frontier approximation.w_min: Minimum risk portfolio weights.w_min_ini: Initial weights for the minimum-risk sub-problem.w_opt: Optimal portfolio weights.w_opt_ini: Initial weights for the optimal sub-problem.w_max: Maximum return portfolio weights.w_max_ini: Initial weights for the maximum-risk sub-problem.ucs_flag: Whether to use the uncertainty set.alg: Near Optimal Centering algorithm variant.fb: Fallback result or estimator.
Constructors
NearOptimalCentering(;
opt::JuMPOptimiser = JuMPOptimiser(),
r::RM_VecRM = Variance(),
obj::Option{<:ObjectiveFunction} = nothing,
bins::Option{<:Number} = nothing,
w_min::Option{<:VecNum} = nothing,
w_min_ini::Option{<:VecNum} = nothing,
w_opt::Option{<:VecNum_VecVecNum} = nothing,
w_opt_ini::Option{<:VecNum_VecVecNum} = nothing,
w_max::Option{<:VecNum} = nothing,
w_max_ini::Option{<:VecNum} = nothing,
ucs_flag::Bool = false,
alg::NearOptimalCenteringAlgorithm = ConstrainedNearOptimalCentering(),
fb::Option{<:OptE_Opt} = nothing
) -> NearOptimalCenteringKeywords correspond to the struct's fields.
Validation
If
ris a vector:!isempty(r).If
w_minis provided:!isempty(w_min).If
w_min_iniis provided:!isempty(w_min_ini).If
w_optis provided:!isempty(w_opt)and!isempty(w_opt_ini).If
w_maxis provided:!isempty(w_max).If
w_max_iniis provided:!isempty(w_max_ini).If
binsis a number:isfinite(bins) && bins > 0.
Mathematical definition
Let
Where:
: Portfolio weight vector. : Feasible weight set defined by portfolio constraints. : Minimum-risk portfolio weights. : User-optimal portfolio weights. : Maximum-risk portfolio weights.
The solution yields a portfolio centrally located within the near-optimal region, robust to small perturbations of the objective.
Related
PortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(opt::NearOptimalCentering) -> AnyReturn true if any sub-estimator of opt requires previous portfolio weights (JuMP optimiser, risk measure, or fallback).
PortfolioOptimisers.factory Method
factory(
noc::NearOptimalCentering,
w::AbstractVector
) -> NearOptimalCentering{JuMPOptimiser{__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict}, _A, _B, _C, _D, _E, _F, _G, _H, _I, Bool, <:NearOptimalCenteringAlgorithm} where {__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict, _A, _B, _C, _D, _E, _F, _G, _H, _I}Build an updated NearOptimalCentering with all estimators that track previous weights updated via factory using w.
PortfolioOptimisers.port_opt_view Method
port_opt_view(
noc::NearOptimalCentering,
i,
X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
args...
) -> NearOptimalCentering{JuMPOptimiser{__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict}, _A, _B, _C, _D, _E, _F, _G, _H, _I, Bool, <:NearOptimalCenteringAlgorithm} where {__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict, _A, _B, _C, _D, _E, _F, _G, _H, _I}Return a cluster-sliced copy of NearOptimalCentering for asset index set i and returns matrix X.
PortfolioOptimisers.near_optimal_centering_risks Function
near_optimal_centering_risks(scalariser, r, pr, fees, slv, w_min, w_opt, w_max)Compute the scaled risk values for the minimum, optimal, and maximum portfolios.
Used internally by Near Optimal Centering to evaluate the risk at the three anchor portfolios (minimum-risk, optimal, maximum-risk) using the given risk measure(s) and scalarisation strategy.
Arguments
scalariser: Risk scalarisation strategy (e.g.SumScalariser,LogSumExpScalariser).r: Risk measure or vector of risk measures.pr: Prior result containing asset data.fees: Optional fees configuration.slv: Solver or vector of solvers.w_min: Minimum-risk portfolio weights.w_opt: Optimal portfolio weights (vector or vector of vectors).w_max: Maximum-risk portfolio weights.
Returns
(risk_min, risk_opt, risk_max): Tuple of risk values at the three anchor portfolios.
Related
sourcePortfolioOptimisers.near_optimal_centering_setup Function
near_optimal_centering_setup(noc::NearOptimalCentering, rd::ReturnsResult; dims::Int = 1)Compute all prerequisite data for Near Optimal Centering.
Solves the minimum-risk, optimal-objective, and maximum-risk sub-problems (unless pre-computed weights are provided), then computes the risk and return targets for the NOC problem.
Arguments
noc::NearOptimalCentering: NOC estimator configuration.rd::ReturnsResult: Returns data.dims::Int: Observation dimension (default1).
Returns
NearOptimalSetupcontaining all setup data needed for the NOC optimisation.
Related
sourcePortfolioOptimisers.set_near_optimal_centering_constraints! Function
set_near_optimal_centering_constraints!(model::JuMP.Model, wb::WeightBounds)Add Near Optimal Centering logarithmic barrier constraints to the JuMP model.
Introduces log variables for portfolio weights, upper bound distances, risk, and return, then adds exponential cone constraints implementing the analytic centre formulation.
Arguments
model::JuMP.Model: JuMP optimisation model.wb::WeightBounds: Weight bounds configuration.
Returns
- Objective expression for the NOC barrier function.
Related
sourcePortfolioOptimisers.set_near_optimal_objective_function! Function
set_near_optimal_objective_function!(alg, model, opt)Set the Near Optimal Centering objective function in the JuMP model.
Formulates the NOC objective based on the algorithm variant. For UnconstrainedNearOptimalCentering, uses only the barrier function. For ConstrainedNearOptimalCentering, also adds objective penalties and custom objective terms.
Arguments
alg: NOC algorithm variant (UnconstrainedNearOptimalCenteringorConstrainedNearOptimalCentering).model::JuMP.Model: JuMP optimisation model.opt::BaseJuMPOptimisationEstimator: JuMP optimiser configuration.
Returns
nothing.
Related
sourcePortfolioOptimisers.solve_noc! Function
solve_noc!(noc, model, rk_opt, rt_opt, opt, args...)Solve the Near Optimal Centering problem given the model, risk, and return targets.
Sets model parameters for the risk and return targets, configures the NOC objective, and solves the JuMP model. Multiple overloads handle different algorithm variants and frontier sweep modes.
Arguments
noc::NearOptimalCentering: NOC estimator configuration.model::JuMP.Model: JuMP optimisation model.rk_opt: Risk target(s) for the NOC problem.rt_opt: Return target(s) for the NOC problem.opt::BaseJuMPOptimisationEstimator: JuMP optimiser configuration.args...: Additional arguments (frontier bounds, flags, etc.).
Returns
(retcode, sol)or(retcodes, sols)depending on the overload.
Related
sourcePortfolioOptimisers.get_overall_retcode Function
get_overall_retcode(w_min_retcode, w_opt_retcode, w_max_retcode, noc_retcode)Compute the overall optimisation return code from individual sub-problem return codes.
Combines the return codes from the minimum, optimal, and maximum weight sub-problems with the near-optimal centering return code to determine the overall status.
Arguments
w_min_retcode: Return code from the minimum weight sub-problem.w_opt_retcode: Return code from the optimal weight sub-problem.w_max_retcode: Return code from the maximum weight sub-problem.noc_retcode: Return code from the near-optimal centering sub-problem.
Returns
- Overall return code.
Related
sourcePortfolioOptimisers.compute_ret_lbs Method
compute_ret_lbs(lbs, args...)Compute the return lower bounds for the efficient frontier sweep.
Dispatches based on the type of lbs: if a pre-computed vector of lower bounds is provided, returns it directly. If a Frontier specification is given, solves the minimum and maximum return sub-problems and constructs a range of bounds.
Arguments
lbs: Pre-computed return bounds vector (VecNum) orFrontierconfiguration.args...: Additional arguments (model, optimiser, prior, etc.) needed whenlbsis aFrontier.
Returns
- Vector or range of return lower bounds for frontier sweep.
Related
sourcePortfolioOptimisers.compute_ret_lbs Method
compute_ret_lbs(lbs::Frontier, model::JuMP.Model, mr::MeanRisk, ret::JuMPReturnsEstimator, pr::AbstractPriorResult, fees::Option{<:Fees})Compute return lower bounds for a MeanRisk efficient frontier sweep by solving minimum and maximum return sub-problems.
Solves the minimum-risk and maximum-return portfolios, then constructs a uniformly spaced range of lbs.N return targets spanning the two extremes.
Arguments
lbs::Frontier: Frontier configuration specifying the number of points.model::JuMP.Model: JuMP optimisation model.mr::MeanRisk: MeanRisk estimator configuration.ret::JuMPReturnsEstimator: Returns estimator.pr::AbstractPriorResult: Prior result with asset moments.fees::Option{<:Fees}: Optional fees configuration.
Returns
- Range of return lower bounds for the frontier sweep.
Related
sourcePortfolioOptimisers.compute_ret_lbs Method
compute_ret_lbs(lbs::Frontier, rt_min::Number, rt_max::Number)Compute return lower bounds for a NearOptimalCentering frontier sweep from pre-computed minimum and maximum return values.
Constructs a uniformly spaced range of lbs.N return targets between rt_min and rt_max.
Arguments
lbs::Frontier: Frontier configuration specifying the number of points.rt_min::Number: Minimum portfolio return (from the minimum-risk portfolio).rt_max::Number: Maximum portfolio return (from the maximum-return portfolio).
Returns
- Range of
lbs.Nequally spaced return lower bounds.
Related
sourcePortfolioOptimisers.compute_risk_ubs Method
compute_risk_ubs(model, opt, ...)Compute or rebuild risk upper bounds for the efficient frontier sweep.
Extracts the risk frontier from the model and rebuilds any frontier bounds that have not yet been computed as numeric vectors.
Arguments
model::JuMP.Model: JuMP optimisation model containing the risk frontier.opt: Optimiser configuration.Additional arguments (prior, fees, weights, etc.).
Returns
- Updated risk frontier vector of pairs.
Related
sourcePortfolioOptimisers.compute_risk_ubs Method
compute_risk_ubs(model::JuMP.Model, noc::NearOptimalCentering{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:ConstrainedNearOptimalCentering}, pr::AbstractPriorResult, fees::Option{<:Fees}, w_min::VecNum, w_max::VecNum)Compute risk upper bounds for a constrained NearOptimalCentering frontier sweep.
Identifies risk frontier entries that are not yet resolved (i.e. not concrete weight vectors) and rebuilds them using the minimum and maximum portfolio weights.
Arguments
model::JuMP.Model: JuMP optimisation model containingrisk_frontier.noc::NearOptimalCentering{..., <:ConstrainedNearOptimalCentering}: Constrained Near Optimal Centering optimiser.pr::AbstractPriorResult: Prior result with asset moments.fees::Option{<:Fees}: Optional fees configuration.w_min::VecNum: Minimum-risk portfolio weights.w_max::VecNum: Maximum-risk (maximum-return) portfolio weights.
Returns
- Updated risk frontier vector of
(keys, vals)pairs.
Related
sourcePortfolioOptimisers.optimise Function
optimise(noc::NearOptimalCentering{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
<:Any, <:Any, <:Any, <:Any, <:Any, Nothing
},
rd::ReturnsResult = ReturnsResult(); dims::Int = 1,
str_names::Bool = false, save::Bool = true, kwargs...) -> NearOptimalCenteringResultRun the Near Optimal Centering portfolio optimisation.
Arguments
noc: The near optimal centering optimiser to use.rd: The returns result to use. Ifisa(noc.opt.pe, AbstractPriorResult),rdis not necessary if doing a standalone optimisation, but may be required/desired by fallbacks and/or clusterisation.dims: The dimension along which observations advance in time.str_names: Whether to use string names for the assets in the optimisation.save: Whether to save the JuMP model in the optimisation result.kwargs: Additional keyword arguments passed to the optimisation function.
Related
source