Base JuMP Optimisation
PortfolioOptimisers.BaseJuMPOptimisationEstimator Type
abstract type BaseJuMPOptimisationEstimator <: BaseOptimisationEstimatorAbstract supertype for base JuMP-based portfolio optimisation estimators.
These are configuration-level types (e.g., JuMPOptimiser) that define the optimisation problem setup for JuMP-based optimisers.
Related
sourcePortfolioOptimisers.JuMPOptimisationEstimator Type
abstract type JuMPOptimisationEstimator <: NonFiniteAllocationOptimisationEstimatorAbstract supertype for JuMP-based portfolio optimisation estimators.
JuMP optimisers formulate and solve portfolio optimisation problems using mathematical programming via the JuMP.jl framework.
Related
sourcePortfolioOptimisers.RiskJuMPOptimisationEstimator Type
abstract type RiskJuMPOptimisationEstimator <: JuMPOptimisationEstimatorAbstract supertype for risk-based JuMP portfolio optimisation estimators.
Subtype RiskJuMPOptimisationEstimator to implement optimisers that minimise or constrain risk measures as the primary objective.
Related
sourcePortfolioOptimisers.ObjectiveFunction Type
abstract type ObjectiveFunction <: AbstractEstimatorAbstract supertype for portfolio objective functions.
Subtype ObjectiveFunction to implement portfolio optimisation objectives such as minimum risk, maximum return, or maximum Sharpe ratio.
Related
sourcePortfolioOptimisers.JuMPReturnsEstimator Type
abstract type JuMPReturnsEstimator <: AbstractEstimatorAbstract supertype for JuMP-based returns estimators used in optimisation models.
JuMPReturnsEstimator types define how expected returns are incorporated into JuMP models.
Related
sourcePortfolioOptimisers.JuMPConstraintEstimator Type
abstract type JuMPConstraintEstimator <: AbstractConstraintEstimatorAbstract supertype for JuMP constraint estimators.
Subtype JuMPConstraintEstimator to implement custom constraints or objectives for JuMP-based portfolio optimisers.
Related
sourcePortfolioOptimisers.CustomJuMPConstraint Type
abstract type CustomJuMPConstraint <: JuMPConstraintEstimatorAbstract supertype for custom JuMP constraint implementations.
Implement add_custom_constraint! to define custom JuMP model constraints.
Related
sourcePortfolioOptimisers.CustomJuMPObjective Type
abstract type CustomJuMPObjective <: JuMPConstraintEstimatorAbstract supertype for custom JuMP objective implementations.
Implement add_custom_objective_term! to add custom terms to the JuMP model objective.
Related
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(_::CustomJuMPConstraint) -> BoolReturn false: custom JuMP constraints never require previous portfolio weights.
PortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(_::CustomJuMPObjective) -> BoolReturn false: custom JuMP objectives never require previous portfolio weights.
PortfolioOptimisers.is_time_dependent Method
is_time_dependent(opt::JuMPOptimisationEstimator) -> AnyReturn true if the estimator's own problem-definition fields, the inner JuMP optimiser, or the fallback carry time-dependent constraints.
PortfolioOptimisers.reset_time_dependent_estimator Method
reset_time_dependent_estimator(
opt::JuMPOptimisationEstimator
) -> AnyReplace time-dependent constraints with their static defaults, both on the estimator's own fields and by recursing into the inner JuMP optimiser and fallback.
sourcePortfolioOptimisers.JuMPOptimisationSolution Type
struct JuMPOptimisationSolution{__T_w} <: OptimisationModelResultStores the solution (portfolio weights) from a JuMP optimisation model.
Fields
w: Portfolio weights vectorassets × 1.
Constructors
JuMPOptimisationSolution(; w::ArrNum) -> JuMPOptimisationSolutionKeywords correspond to the struct's fields.
Validation
!isempty(w).
Related
sourcePortfolioOptimisers.VecJuMPOptSol Type
const VecJuMPOptSol = AbstractVector{<:JuMPOptimisationSolution}Alias for a vector of JuMP optimisation solutions.
Related
sourcePortfolioOptimisers.JuMPOptSol_VecJuMPOptSol Type
const JuMPOptSol_VecJuMPOptSol = Union{<:JuMPOptimisationSolution, <:VecJuMPOptSol}Alias for a single JuMP optimisation solution or a vector of them.
Related
sourcePortfolioOptimisers.BaseJuMPOptimisationResult Type
abstract type BaseJuMPOptimisationResult <: AbstractResultAbstract supertype for the embedded JuMP optimisation result core.
Mirrors BaseJuMPOptimisationEstimator: the factored-out struct holding the fields common to every JuMP-based optimisation result lives on this branch and is not part of the optimisation result hierarchy. The concrete core is JuMPOptimisationResult.
Related
sourcePortfolioOptimisers.RiskJuMPOptimisationResult Type
abstract type RiskJuMPOptimisationResult <: NonFiniteAllocationOptimisationResultAbstract supertype for JuMP-based continuous optimisation results.
The JuMP half of the result split; mirrors RiskJuMPOptimisationEstimator. Concrete subtypes embed a JuMPOptimisationResult as their first field (jr) and add only their unique fields plus the trailing fb. The default getproperty resolves unique fields directly and delegates everything else (including :w and the pa fall-through) to jr; types with composed sub-result fields override it to forward into those first.
Related
sourceBase.propertynames Method
propertynames(r::RiskJuMPOptimisationResult) -> TupleDefault property enumeration for RiskJuMPOptimisationResult: mirrors the default getproperty by unioning the receiver's own field names with everything forwarded from the embedded JuMPOptimisationResult jr (which itself forwards pa). Concrete subtypes that override getproperty (e.g. via @forward_properties) emit their own, more-specific propertynames.
Base.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.NonJuMPOptimisationResult Type
abstract type NonJuMPOptimisationResult <: NonFiniteAllocationOptimisationResultAbstract supertype for non-JuMP continuous optimisation results.
Groups the results that do not carry a JuMP model (naive, clustering, and meta-optimiser results). Mirrors the JuMP/non-JuMP split on the result side; the JuMP half is RiskJuMPOptimisationResult.
Related
PortfolioOptimisers.add_custom_objective_term! Function
add_custom_objective_term!(args...; kwargs...)Add a custom objective term to the JuMP model.
No-op fallback. Override this method for subtypes of CustomJuMPObjective to add custom penalty or reward terms to the JuMP model objective.
Arguments
args...: JuMP model and custom objective type (ignored in fallback).kwargs...: Additional keyword arguments.
Returns
nothing.
Related
sourcePortfolioOptimisers.add_custom_constraint! Function
add_custom_constraint!(args...; kwargs...)Add a custom constraint to the JuMP model.
No-op fallback. Override this method for subtypes of CustomJuMPConstraint to add custom constraints to the JuMP model.
Arguments
args...: JuMP model and custom constraint type (ignored in fallback).kwargs...: Additional keyword arguments.
Returns
nothing.
Related
sourcePortfolioOptimisers.process_model Function
process_model(model, retcode)Extract the solution from an optimised JuMP model based on the return code.
On success, extracts the optimised weights from the model. On failure, returns an empty solution.
Arguments
model: Optimised JuMP model.retcode: Optimisation return code (OptimisationSuccessorOptimisationFailure).
Returns
- Solution object.
Related
sourcePortfolioOptimisers.optimise_JuMP_model! Function
optimise_JuMP_model!(model::JuMP.Model, slv::Slv_VecSlv)Attempt to optimise a JuMP model using one or more configured solvers.
Tries each solver in order, applying settings and checking for solution feasibility. Returns a JuMPResult with trial errors and success status.
Arguments
model: JuMP model to optimise.slv: SingleSolveror vector ofSolverobjects.
Returns
res::JuMPResult: Result object containing trial errors and success flag.
Details
For each solver, sets the optimizer and attributes, runs
JuMP.optimize!, and checks solution feasibility.If a solver fails, records the error and tries the next.
Stops at the first successful solution.
Related
sourceoptimise_JuMP_model!(
model::Model,
opt::JuMPOptimisationEstimator
) -> Tuple{Union{OptimisationFailure{Dict{Any, Any}}, OptimisationSuccess{Dict{Any, Any}}}, JuMPOptimisationSolution{<:AbstractArray{var"#s30", N}} where {var"#s30"<:(Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}), N}}
optimise_JuMP_model!(
model::Model,
opt::JuMPOptimisationEstimator,
datatype::DataType
) -> Tuple{Union{OptimisationFailure{Dict{Any, Any}}, OptimisationSuccess{Dict{Any, Any}}}, JuMPOptimisationSolution{<:AbstractArray{var"#s30", N}} where {var"#s30"<:(Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}), N}}Attempt to solve the JuMP model using each solver in opt.opt.slv in order.
Tries each solver sequentially, checking feasibility and finite non-zero weights. Returns a (retcode, solution) tuple where retcode is OptimisationSuccess or OptimisationFailure and solution is a JuMPOptimisationSolution.
Related
sourcePortfolioOptimisers.set_model_scales! Function
set_model_scales!(model::JuMP.Model, so::Number, sc::Number)Register objective scale so and constraint scale sc as named expressions in the JuMP model.
Arguments
model::JuMP.Model: JuMP optimisation model.so::Number: Objective scale factor.sc::Number: Constraint scale factor.
Returns
nothing.
Related
sourcePortfolioOptimisers.set_initial_w! Function
set_initial_w!(args...)
set_initial_w!(w::VecNum, wi::VecNum)Set initial (warm-start) values for portfolio weight variables in the JuMP model.
The no-op fallback does nothing when wi is not provided. The two-argument method sets JuMP start values for each weight variable.
Arguments
w::VecNum: Vector of JuMP weight variables.wi::VecNum: Vector of initial weight values.
Returns
nothing.
Related
sourcePortfolioOptimisers.set_w! Function
set_w!(model::JuMP.Model, X::MatNum, wi::Option{<:VecNum_VecVecNum})Create portfolio weight variables in the JuMP model and optionally set initial values.
Registers a vector of weight variables w of length size(X, 2) in the model. If wi is provided, sets the initial values via set_initial_w!.
Arguments
model::JuMP.Model: JuMP optimisation model.X::MatNum: Asset returns matrix (shape: observations × assets).wi: Optional initial weight values.
Returns
nothing.
Related
sourcePortfolioOptimisers.set_portfolio_returns! Function
set_portfolio_returns!(model::JuMP.Model, X::MatNum)Compute and register portfolio returns expression X * w in the JuMP model.
If the expression already exists in the model, returns it directly (idempotent).
Arguments
model::JuMP.Model: JuMP optimisation model.X::MatNum: Asset returns matrix.
Returns
- The portfolio returns expression.
Related
sourcePortfolioOptimisers.set_net_portfolio_returns! Function
set_net_portfolio_returns!(model::JuMP.Model, X::MatNum)Compute and register net portfolio returns (after fees) in the JuMP model.
Calls set_portfolio_returns! and subtracts fees if present.
Arguments
model::JuMP.Model: JuMP optimisation model.X::MatNum: Asset returns matrix.
Returns
- The net portfolio returns expression.
Related
sourcePortfolioOptimisers.set_asset_returns_plus_one! Function
set_asset_returns_plus_one!(model::JuMP.Model, X::MatNum)Compute and register portfolio asset gross returns X .+ 1 in the JuMP model.
Used in drawdown and logarithmic return computations.
Arguments
model::JuMP.Model: JuMP optimisation model.X::MatNum: Asset returns expression.
Returns
- The gross asset returns expression
X .+ 1.
Related
sourcePortfolioOptimisers.set_asset_neg_returns_plus_one! Function
set_asset_neg_returns_plus_one!(model::JuMP.Model, X::MatNum)Compute and register negative asset gross returns -X .+ 1 in the JuMP model.
Used in drawdown and logarithmic return computations.
Arguments
model::JuMP.Model: JuMP optimisation model.X::MatNum: Asset returns expression.
Returns
- The negative gross asset returns expression
-X .+ 1.
Related
sourcePortfolioOptimisers.set_portfolio_drawdowns_plus_one! Function
set_portfolio_drawdowns_plus_one!(model::JuMP.Model, X::MatNum)Compute and register absolute drawdowns plus one in the JuMP model.
Computes absolute_drawdown_arr(X) .+ 1 and registers it in the model.
Arguments
model::JuMP.Model: JuMP optimisation model.X::MatNum: Portfolio returns expression.
Returns
- The drawdowns-plus-one expression.
Related
sourcePortfolioOptimisers.set_risk_constraints! Function
set_risk_constraints!(model, r, X, T, ...) -> nothingSet risk constraints in the JuMP model for a given risk measure.
Generic function stub; concrete methods are defined in constraint and risk measure files. Each method configures the appropriate risk constraint expressions for a given risk measure type r.
Related
sourcePortfolioOptimisers.get_constraint_scale Function
get_constraint_scale(model::JuMP.Model)Return the constraint scale expression model[:sc].
Asserts the scale has been registered (via set_model_scales!); errors otherwise.
Related
sourcePortfolioOptimisers.has_Xap1 Function
has_Xap1(model::JuMP.Model, prefix::Symbol = Symbol(""))Return true if the gross portfolio returns model[Symbol(prefix, :Xap1)] have been registered (via set_asset_returns_plus_one!).
Related
sourcePortfolioOptimisers.get_ret Function
get_ret(model::JuMP.Model)Return the portfolio expected-return expression model[:ret].
Asserts the return expression has been registered; errors otherwise.
Related
sourcePortfolioOptimisers.get_net_X Function
get_net_X(model::JuMP.Model, prefix::Symbol = Symbol(""))Return the net portfolio returns expression model[Symbol(prefix, :net_X)].
Asserts it has been registered (via set_net_portfolio_returns!); errors otherwise.
Related
sourcePortfolioOptimisers.get_ddap1 Function
get_ddap1(model::JuMP.Model, prefix::Symbol = Symbol(""))Return the drawdowns-plus-one expression model[Symbol(prefix, :ddap1)].
Asserts it has been registered (via set_portfolio_drawdowns_plus_one!); errors otherwise.
Related
sourcePortfolioOptimisers.get_w Function
get_w(model::JuMP.Model)Return the portfolio weight variables model[:w].
Asserts the weights have been registered (via set_w!); errors otherwise.
Related
sourcePortfolioOptimisers.get_objective_scale Function
get_objective_scale(model::JuMP.Model)Return the objective scale expression model[:so].
Asserts the scale has been registered (via set_model_scales!); errors otherwise.
Related
sourcePortfolioOptimisers.get_k Function
get_k(model::JuMP.Model)Return the homogenisation variable model[:k].
k >= 0 is the auxiliary scaling variable used to homogenise fractional/ratio objectives (e.g. maximum ratio); recovered weights are w / k. Asserts :k has been registered; errors otherwise.
Related
sourcePortfolioOptimisers.get_Xap1 Function
get_Xap1(model::JuMP.Model, prefix::Symbol = Symbol(""))Return the gross portfolio returns expression model[Symbol(prefix, :Xap1)] (X .+ 1).
Asserts it has been registered (via set_asset_returns_plus_one!); errors otherwise.
Related
sourcePortfolioOptimisers.has_ddap1 Function
has_ddap1(model::JuMP.Model, prefix::Symbol = Symbol(""))Return true if the drawdowns-plus-one model[Symbol(prefix, :ddap1)] have been registered (via set_portfolio_drawdowns_plus_one!).
Related
sourcePortfolioOptimisers.has_net_X Function
has_net_X(model::JuMP.Model, prefix::Symbol = Symbol(""))Return true if the net portfolio returns model[Symbol(prefix, :net_X)] have been registered (via set_net_portfolio_returns!).
Related
sourcePortfolioOptimisers.get_X Function
get_X(model::JuMP.Model, prefix::Symbol = Symbol(""))Return the portfolio returns expression model[Symbol(prefix, :X)].
Asserts it has been registered (via set_portfolio_returns!); errors otherwise.
Related
sourcePortfolioOptimisers.get_risk Function
get_risk(model::JuMP.Model)Return the scalarised portfolio risk expression model[:risk].
Asserts the risk expression has been registered (via scalarise_risk_expression!); errors otherwise.
Related
sourcePortfolioOptimisers.get_dd Function
get_dd(model::JuMP.Model, prefix::Symbol = Symbol(""))Return the cumulative-drawdown variables model[Symbol(prefix, :dd)].
Asserts they have been registered (via set_drawdown_constraints!); errors otherwise.
Related
sourcePortfolioOptimisers.has_X Function
has_X(model::JuMP.Model, prefix::Symbol = Symbol(""))Return true if the portfolio returns model[Symbol(prefix, :X)] have been registered (via set_portfolio_returns!).
Related
sourcePortfolioOptimisers.has_dd Function
has_dd(model::JuMP.Model, prefix::Symbol = Symbol(""))Return true if the cumulative-drawdown variables model[Symbol(prefix, :dd)] have been registered (via set_drawdown_constraints!).
Related
sourcePortfolioOptimisers.preg! Function
preg!(model::JuMP.Model, prefix::Symbol, name::Symbol, val)Register val in the model under the prefixed key Symbol(prefix, name) and return it.
The single place the model-state namespacing convention lives: a nested risk build (e.g. risk tracking) passes a non-empty prefix so the shared infrastructure keys it creates (:X, :net_X, :W, :dd, …) do not collide with the outer model's; the default empty prefix reproduces the bare key. Pairs with the prefixed read accessors. See ADR 0004.
Related
source