Skip to content
13

Base Uncertainty Sets

PortfolioOptimisers.BoxUncertaintySet Type
julia
struct BoxUncertaintySet{__T_lb, __T_ub} <: AbstractUncertaintySetResult

Represents a box uncertainty set for risk or prior statistics in portfolio optimisation. Stores lower and upper bounds for the uncertain quantity, such as expected returns or covariance.

Uμbox={μ||μμ^|δ}UΣbox={Σ|ΣlΣΣu,Σ0}

Fields

  • lb: Lower bound array for the uncertainty set.

  • ub: Upper bound array for the uncertainty set.

Constructors

julia
BoxUncertaintySet(;
    lb::ArrNum,
    ub::ArrNum
) -> BoxUncertaintySet

Keywords correspond to the struct's fields.

Validation

  • !isempty(lb).

  • !isempty(ub).

  • size(lb) == size(ub).

Examples

julia
julia> BoxUncertaintySet(; lb = [0.1, 0.2], ub = [0.3, 0.4])
BoxUncertaintySet
  lb ┼ Vector{Float64}: [0.1, 0.2]
  ub ┴ Vector{Float64}: [0.3, 0.4]

Related

source
PortfolioOptimisers.BoxUncertaintySetAlgorithm Type
julia
struct BoxUncertaintySetAlgorithm <: AbstractUncertaintySetAlgorithm

Algorithm for constructing box uncertainty sets in portfolio optimisation. Box uncertainty sets model uncertainty by specifying lower and upper bounds for risk or prior statistics.

Related

source
PortfolioOptimisers.MuEllipsoidalUncertaintySet Type
julia
struct MuEllipsoidalUncertaintySet <: AbstractEllipsoidalUncertaintySetResultClass

Represents the class identifier for mean ellipsoidal uncertainty sets in portfolio optimisation.

Used to distinguish ellipsoidal uncertainty sets that encode uncertainty for mean statistics, such as expected returns.

Related

source
PortfolioOptimisers.SigmaEllipsoidalUncertaintySet Type
julia
struct SigmaEllipsoidalUncertaintySet <: AbstractEllipsoidalUncertaintySetResultClass

Represents the class identifier for covariance ellipsoidal uncertainty sets in portfolio optimisation.

Used to distinguish ellipsoidal uncertainty sets that encode uncertainty for covariance statistics, such as covariance matrices.

Related

source
PortfolioOptimisers.NormalKUncertaintyAlgorithm Type
julia
struct NormalKUncertaintyAlgorithm{__T_kwargs} <: AbstractUncertaintyKAlgorithm

Algorithm for computing the scaling parameter k for ellipsoidal uncertainty sets under the assumption of normally distributed returns in portfolio optimisation.

Fields

  • kwargs: Named tuple of keyword arguments for quantile calculation.

Constructors

julia
NormalKUncertaintyAlgorithm(;
    kwargs::NamedTuple = (;)
)

Keyword arguments correspond to the field above.

Validation

  • kwargs must be a valid NamedTuple.

Examples

julia
julia> NormalKUncertaintyAlgorithm()
NormalKUncertaintyAlgorithm
  kwargs ┴ @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.GeneralKUncertaintyAlgorithm Type
julia
struct GeneralKUncertaintyAlgorithm <: AbstractUncertaintyKAlgorithm

Algorithm for computing the scaling parameter k for ellipsoidal uncertainty sets using a general formula sqrt((1 - q) / q), this ignores the distribution of the underlying data.

Related

source
PortfolioOptimisers.ChiSqKUncertaintyAlgorithm Type
julia
struct ChiSqKUncertaintyAlgorithm <: AbstractUncertaintyKAlgorithm

Algorithm for computing the scaling parameter k for ellipsoidal uncertainty sets using the chi-squared distribution in portfolio optimisation.

Related

source
PortfolioOptimisers.EllipsoidalUncertaintySet Type
julia
struct EllipsoidalUncertaintySet{__T_sigma, __T_k, __T_class} <: AbstractUncertaintySetResult

Represents an ellipsoidal uncertainty set for risk or prior statistics in portfolio optimisation. Stores a covariance matrix, a scaling parameter, and a class identifier for the uncertain quantity, such as expected returns or covariance.

Uμellip={μ|(μμ^)Σμ1(μμ^)kμ2}UΣellip={Σ|(vec(Σ)vec(Σ^))ΣΣ1(vec(Σ)vec(Σ^))kΣ2,Σ0}

Fields

  • sigma: Covariance matrix for the uncertainty set.

  • k: Scaling parameter for the ellipsoidal.

  • class: Identifier for the type of ellipsoidal uncertainty set (e.g., mean or covariance).

Constructors

julia
EllipsoidalUncertaintySet(;
    sigma::MatNum,
    k::Number,
    class::AbstractEllipsoidalUncertaintySetResultClass
) -> EllipsoidalUncertaintySet

Keywords correspond to the struct's fields.

Validation

  • !isempty(sigma).

  • size(sigma, 1) == size(sigma, 2).

  • k > 0.

Examples

julia
julia> EllipsoidalUncertaintySet([1.0 0.2; 0.2 1.0], 2.5, SigmaEllipsoidalUncertaintySet())
EllipsoidalUncertaintySet
  sigma ┼ 2×2 Matrix{Float64}
      k ┼ Float64: 2.5
  class ┴ SigmaEllipsoidalUncertaintySet()

Related

source
PortfolioOptimisers.EllipsoidalUncertaintySetAlgorithm Type
julia
struct EllipsoidalUncertaintySetAlgorithm{__T_method, __T_diagonal} <: AbstractUncertaintySetAlgorithm

Algorithm for constructing ellipsoidal uncertainty sets in portfolio optimisation. Ellipsoidal uncertainty sets model uncertainty by specifying an ellipsoidal region for risk or prior statistics, typically using a covariance matrix and a scaling parameter.

Fields

  • method: Algorithm or value used to determine the scaling parameter for the ellipsoidal.

  • diagonal: Indicates whether to use only the diagonal elements of the covariance matrix.

Constructors

julia
EllipsoidalUncertaintySetAlgorithm(;
    method::Num_UcSK = ChiSqKUncertaintyAlgorithm(),
    diagonal::Bool = true
) -> EllipsoidalUncertaintySetAlgorithm
  • method: Sets the scaling algorithm or value for the ellipsoidal.

  • diagonal: Sets whether to use only diagonal elements.

Examples

julia
julia> EllipsoidalUncertaintySetAlgorithm()
EllipsoidalUncertaintySetAlgorithm
    method ┼ ChiSqKUncertaintyAlgorithm()
  diagonal ┴ Bool: true

Related

source
PortfolioOptimisers.ucs Method
julia
ucs(uc::Option{<:Tuple{<:Option{<:AbstractUncertaintySetResult},
                       <:Option{<:AbstractUncertaintySetResult}}}, args...; kwargs...)

Returns the argument(s) unchanged. This is a no-op function used to handle cases where uncertainty sets are pre-processed (nothing or a tuple of results).

Arguments

  • uc: Tuple of uncertainty sets, or nothing.

  • args...: Additional positional arguments (ignored).

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • uc::Option{<:Tuple{<:Option{<:AbstractUncertaintySetResult}, <:Option{<:AbstractUncertaintySetResult}}}: The input, unchanged.

Related

source
PortfolioOptimisers.ucs Method
julia
ucs(uc::AbstractUncertaintySetEstimator, rd::ReturnsResult; kwargs...)

Constructs an uncertainty set from a given estimator and returns data.

Arguments

  • uc: Uncertainty set estimator. Used to construct the uncertainty set.

  • rd: ReturnsResult. Contains the returns data and associated metadata.

  • kwargs...: Additional keyword arguments passed to the estimator.

Returns

  • uc::Tuple{<:AbstractUncertaintySetResult, <:AbstractUncertaintySetResult}: Expected returns and covariance uncertainty sets.

Details

  • Calls the estimator on the returns data and metadata in rd.

  • Passes rd.X, rd.F, and relevant metadata (iv, ivpa) to the estimator.

  • Additional keyword arguments are forwarded.

  • Used for compatibility with ReturnsResult objects.

Related

source
PortfolioOptimisers.mu_ucs Method
julia
mu_ucs(uc::Option{<:AbstractUncertaintySetResult}, args...; kwargs...)

Returns the argument unchanged. This is a no-op function used to handle cases where the expected returns uncertainty set is already a result or is absent (nothing).

Arguments

  • uc: Expected returns uncertainty set or nothing.

  • args...: Additional positional arguments (ignored).

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • uc::Option{<:AbstractUncertaintySetResult}: The input, unchanged.

Related

source
PortfolioOptimisers.mu_ucs Method
julia
mu_ucs(uc::AbstractUncertaintySetEstimator, rd::ReturnsResult; kwargs...)

Constructs an expected returns uncertainty set from a given estimator and returns data.

Arguments

  • uc: Uncertainty set estimator. Used to construct the expected returns uncertainty set.

  • rd: ReturnsResult. Contains the returns data and associated metadata.

  • kwargs...: Additional keyword arguments passed to the estimator.

Returns

  • uc::AbstractUncertaintySetResult: Expected returns uncertainty set.

Details

  • Calls the estimator on the returns data and metadata in rd.

  • Passes rd.X, rd.F, and relevant metadata (iv, ivpa) to the estimator.

  • Additional keyword arguments are forwarded.

  • Used for compatibility with ReturnsResult objects.

Related

source
PortfolioOptimisers.sigma_ucs Method
julia
sigma_ucs(uc::Option{<:AbstractUncertaintySetResult}, args...; kwargs...)

Returns the argument unchanged. This is a no-op function used to handle cases where the covariance uncertainty set is already a result or is absent (nothing).

Arguments

  • uc: Covariance uncertainty set or nothing.

  • args...: Additional positional arguments (ignored).

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • uc::Option{<:AbstractUncertaintySetResult}: The input, unchanged.

Related

source
PortfolioOptimisers.AbstractUncertaintySetEstimator Type
julia
abstract type AbstractUncertaintySetEstimator <: AbstractEstimator

Defines the abstract interface for uncertainty set estimators in portfolio optimisation. Subtypes of this abstract type are responsible for constructing and estimating uncertainty sets for risk or prior statistics, such as box or ellipsoidal uncertainty sets.

Related

source
PortfolioOptimisers.AbstractUncertaintySetAlgorithm Type
julia
abstract type AbstractUncertaintySetAlgorithm <: AbstractAlgorithm

Defines the abstract interface for algorithms that construct uncertainty sets in portfolio optimisation. Subtypes implement specific methods for generating uncertainty sets, such as box or ellipsoidal uncertainty sets, which are used to model uncertainty in risk or prior statistics.

Related

source
PortfolioOptimisers.AbstractUncertaintySetResult Type
julia
abstract type AbstractUncertaintySetResult <: AbstractResult

Abstract type for results produced by uncertainty set algorithms in portfolio optimisation.

Represents the interface for all result types that encode uncertainty sets for risk or prior statistics, such as box or ellipsoidal uncertainty sets. Subtypes store the output of uncertainty set estimation or construction algorithms.

Related

source
PortfolioOptimisers.AbstractUncertaintyKAlgorithm Type
julia
abstract type AbstractUncertaintyKAlgorithm <: AbstractAlgorithm

Defines the abstract interface for algorithms that compute the scaling parameter k for ellipsoidal uncertainty sets in portfolio optimisation.

Subtypes implement specific methods for generating the scaling parameter, which controls the size of the ellipsoidal region representing uncertainty in risk or prior statistics.

Related

source
PortfolioOptimisers.AbstractEllipsoidalUncertaintySetResultClass Type
julia
abstract type AbstractEllipsoidalUncertaintySetResultClass <: AbstractUncertaintySetResult

Defines the abstract interface for ellipsoidal uncertainty set result classes in portfolio optimisation.

Subtypes of this abstract type represent the class or category of ellipsoidal uncertainty sets, such as those for mean or covariance statistics. Used to distinguish between different types of ellipsoidal uncertainty set results.

Related

source
PortfolioOptimisers.ucs_selector Function
julia
ucs_selector(risk_ucs::Nothing, prior_ucs::Nothing)
ucs_selector(risk_ucs::UcSE_UcS, prior_ucs::Any)
ucs_selector(risk_ucs::Nothing, prior_ucs::UcSE_UcS)

Function for selecting uncertainty sets from risk measure or prior result instances.

Arguments

  • risk_ucs: Risk measure uncertainty set estimator or result, or nothing.

  • prior_ucs: Prior result uncertainty set estimator or result, or nothing.

Returns

Based on the argument types, returns one of the following:

  • nothing: If both risk_ucs and prior_ucs are nothing.

  • risk_ucs::UcSE_UcS: If risk_ucs is not nothing.

  • prior_ucs::UcSE_UcS: If risk_ucs is nothing but prior_ucs is not nothing.

Related

source
PortfolioOptimisers.k_ucs Function
julia
k_ucs(km::NormalKUncertaintyAlgorithm, q::Number, X::MatNum, sigma_X::MatNum)
k_ucs(::GeneralKUncertaintyAlgorithm, q::Number, args...)
k_ucs(::ChiSqKUncertaintyAlgorithm, q::Number, X::ArrNum, args...)
k_ucs(type::Number, args...)

Computes the scaling parameter k for ellipsoidal uncertainty sets in portfolio optimisation.

Arguments

  • km: Scaling algorithm instance.

  • q: Quantile or confidence level.

  • X: Data matrix (returns).

  • sigma_X: Covariance matrix.

  • args...: Additional arguments.

  • type: Number value for direct scaling.

Returns

  • k::Number: Scaling parameter.

Details

  • Uses different algorithms to compute the scaling parameter:

    • Normal: 1 - q-th quantile of the Mahalanobis distances.

    • General: formula sqrt((1 - q) / q).

    • Chi-squared: 1 - q-th quantile of the chi-squared distribution.

    • Number: returns the provided value directly.

  • Supports multiple dispatch for extensibility.

Related

source