Base Uncertainty Sets
PortfolioOptimisers.BoxUncertaintySet Type
struct BoxUncertaintySet{__T_lb, __T_ub} <: AbstractUncertaintySetResultRepresents 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.
Mathematical definition
Where:
: Box uncertainty set for expected returns. : Box uncertainty set for the covariance matrix. , : Uncertain expected returns and covariance. : Estimated (reference) mean vector. : Half-width of the box (element-wise). , : Lower and upper bounds for the covariance matrix. : Positive semi-definiteness constraint.
Fields
lb: Lower bound.ub: Upper bound.
Constructors
BoxUncertaintySet(;
lb::ArrNum,
ub::ArrNum
) -> BoxUncertaintySetKeywords correspond to the struct's fields.
Validation
!isempty(lb).!isempty(ub).size(lb) == size(ub).
Examples
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
sourcePortfolioOptimisers.BoxUncertaintySetAlgorithm Type
struct BoxUncertaintySetAlgorithm <: AbstractUncertaintySetAlgorithmAlgorithm 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
sourcePortfolioOptimisers.MuEllipsoidalUncertaintySet Type
struct MuEllipsoidalUncertaintySet <: AbstractEllipsoidalUncertaintySetResultClassRepresents 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
sourcePortfolioOptimisers.SigmaEllipsoidalUncertaintySet Type
struct SigmaEllipsoidalUncertaintySet <: AbstractEllipsoidalUncertaintySetResultClassRepresents 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
sourcePortfolioOptimisers.NormalKUncertaintyAlgorithm Type
struct NormalKUncertaintyAlgorithm{__T_kwargs} <: AbstractUncertaintyKAlgorithmAlgorithm for computing the scaling parameter k for ellipsoidal uncertainty sets under the assumption of normally distributed returns in portfolio optimisation.
Fields
kwargs: Additional keyword arguments.
Constructors
NormalKUncertaintyAlgorithm(;
kwargs::NamedTuple = (;)
)Keyword arguments correspond to the field above.
Validation
kwargsmust be a validNamedTuple.
Examples
julia> NormalKUncertaintyAlgorithm()
NormalKUncertaintyAlgorithm
kwargs ┴ @NamedTuple{}: NamedTuple()Related
sourcePortfolioOptimisers.GeneralKUncertaintyAlgorithm Type
struct GeneralKUncertaintyAlgorithm <: AbstractUncertaintyKAlgorithmAlgorithm 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
sourcePortfolioOptimisers.ChiSqKUncertaintyAlgorithm Type
struct ChiSqKUncertaintyAlgorithm <: AbstractUncertaintyKAlgorithmAlgorithm for computing the scaling parameter k for ellipsoidal uncertainty sets using the chi-squared distribution in portfolio optimisation.
Related
sourcePortfolioOptimisers.EllipsoidalUncertaintySet Type
struct EllipsoidalUncertaintySet{__T_sigma, __T_k, __T_class} <: AbstractUncertaintySetResultRepresents 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.
Mathematical definition
Where:
: Ellipsoidal uncertainty set for expected returns. : Ellipsoidal uncertainty set for covariance matrix. , : Uncertain expected returns and covariance. , : Estimated reference mean and covariance. : Covariance matrix of estimation error in mean. : Covariance matrix of estimation error in covariance (vectorised). , : Scaling parameters (squared ellipsoid radii). : Vectorisation operator (column-stacking). : Positive semi-definiteness constraint.
Fields
sigma: Covariance matrixfeatures × features.k: Uncertainty set scaling parameter.class: Uncertainty set class.
Constructors
EllipsoidalUncertaintySet(;
sigma::MatNum,
k::Number,
class::AbstractEllipsoidalUncertaintySetResultClass
) -> EllipsoidalUncertaintySetKeywords correspond to the struct's fields.
Validation
!isempty(sigma).size(sigma, 1) == size(sigma, 2).k > 0.
Examples
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
sourcePortfolioOptimisers.EllipsoidalUncertaintySetAlgorithm Type
struct EllipsoidalUncertaintySetAlgorithm{__T_method, __T_diagonal} <: AbstractUncertaintySetAlgorithmAlgorithm 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: Ellipsoidal uncertainty set estimation method.diagonal: Whether to use only the diagonal of the covariance matrix.
Constructors
EllipsoidalUncertaintySetAlgorithm(;
method::Num_UcSK = ChiSqKUncertaintyAlgorithm(),
diagonal::Bool = true
) -> EllipsoidalUncertaintySetAlgorithmmethod: Sets the scaling algorithm or value for the ellipsoidal.diagonal: Sets whether to use only diagonal elements.
Examples
julia> EllipsoidalUncertaintySetAlgorithm()
EllipsoidalUncertaintySetAlgorithm
method ┼ ChiSqKUncertaintyAlgorithm()
diagonal ┴ Bool: trueRelated
PortfolioOptimisers.ucs Method
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, ornothing.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
uc::Option{<:Tuple{<:Option{<:AbstractUncertaintySetResult}, <:Option{<:AbstractUncertaintySetResult}}}: The input, unchanged.
Related
sourcePortfolioOptimisers.ucs Method
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
ReturnsResultobjects.
Related
sourcePortfolioOptimisers.mu_ucs Method
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 ornothing.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
uc::Option{<:AbstractUncertaintySetResult}: The input, unchanged.
Related
sourcePortfolioOptimisers.mu_ucs Method
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
ReturnsResultobjects.
Related
sourcePortfolioOptimisers.sigma_ucs Method
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 ornothing.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
uc::Option{<:AbstractUncertaintySetResult}: The input, unchanged.
Related
sourcePortfolioOptimisers.sigma_ucs Method
sigma_ucs(uc::AbstractUncertaintySetEstimator, rd::ReturnsResult; kwargs...)Constructs a covariance uncertainty set from a given estimator and returns data.
Arguments
uc: Uncertainty set estimator. Used to construct the covariance uncertainty set.rd: ReturnsResult. Contains the returns data and associated metadata.kwargs...: Additional keyword arguments passed to the estimator.
Returns
uc::AbstractUncertaintySetResult: Covariance 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
ReturnsResultobjects.
Related
sourcePortfolioOptimisers.AbstractUncertaintySetEstimator Type
abstract type AbstractUncertaintySetEstimator <: AbstractEstimatorDefines 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
sourcePortfolioOptimisers.AbstractUncertaintySetAlgorithm Type
abstract type AbstractUncertaintySetAlgorithm <: AbstractAlgorithmDefines 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
PortfolioOptimisers.AbstractUncertaintySetResult Type
abstract type AbstractUncertaintySetResult <: AbstractResultAbstract 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
PortfolioOptimisers.AbstractUncertaintyKAlgorithm Type
abstract type AbstractUncertaintyKAlgorithm <: AbstractAlgorithmDefines 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
sourcePortfolioOptimisers.UcSE_UcS Type
const UcSE_UcS = Union{<:AbstractUncertaintySetResult, <:AbstractUncertaintySetEstimator}Alias for a union of uncertainty set result and estimator types.
Related
sourcePortfolioOptimisers.Num_UcSK Type
const Num_UcSK = Union{<:AbstractUncertaintyKAlgorithm, <:Number}Alias for a union of uncertainty scaling algorithm and numeric types.
Related
sourcePortfolioOptimisers.AbstractEllipsoidalUncertaintySetResultClass Type
abstract type AbstractEllipsoidalUncertaintySetResultClass <: AbstractUncertaintySetResultDefines 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
sourcePortfolioOptimisers.ucs_selector Function
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, ornothing.prior_ucs: Prior result uncertainty set estimator or result, ornothing.
Returns
Based on the argument types, returns one of the following:
nothing: If bothrisk_ucsandprior_ucsarenothing.risk_ucs::UcSE_UcS: Ifrisk_ucsis notnothing.prior_ucs::UcSE_UcS: Ifrisk_ucsisnothingbutprior_ucsis notnothing.
Related
sourcePortfolioOptimisers.k_ucs Function
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
PortfolioOptimisers.port_opt_view Method
port_opt_view(risk_ucs, i)Get a view or subset of an uncertainty set for asset cluster index i.
Returns the uncertainty set sliced for the given index, or unchanged for estimator types. Used in hierarchical optimisation to apply uncertainty sets per cluster.
Arguments
risk_ucs: Uncertainty set result, estimator, ornothing.i: Cluster or asset index.
Returns
- Sliced uncertainty set or unchanged value.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
risk_ucs::BoxUncertaintySet{<:AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}, <:AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}},
i,
args...
) -> BoxUncertaintySet{var"#s179", <:AbstractArray{var"#s21", N}} where {var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}), N, var"#s179"<:AbstractArray{var"#s21", N}, var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}), N}Return a view of a vector BoxUncertaintySet restricted to the asset indices i.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
risk_ucs::BoxUncertaintySet{<:AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}, <:AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}},
i,
args...
) -> BoxUncertaintySet{var"#s179", <:AbstractArray{var"#s21", N}} where {var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}), N, var"#s179"<:AbstractArray{var"#s21", N}, var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}), N}Return a view of a matrix BoxUncertaintySet restricted to the asset indices i.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
risk_ucs::EllipsoidalUncertaintySet{<:AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}, <:Any, <:SigmaEllipsoidalUncertaintySet},
i,
args...
) -> EllipsoidalUncertaintySet{<:AbstractMatrix{var"#s21"}, <:Number, SigmaEllipsoidalUncertaintySet} where var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar})Return a view of a covariance EllipsoidalUncertaintySet restricted to assets at index i, mapping the sigma index via cokurtosis index generation.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
risk_ucs::EllipsoidalUncertaintySet{<:AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}, <:Any, <:MuEllipsoidalUncertaintySet},
i,
args...
) -> EllipsoidalUncertaintySet{<:AbstractMatrix{var"#s21"}, <:Number, MuEllipsoidalUncertaintySet} where var"#s21"<:(Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar})Return a view of a mean EllipsoidalUncertaintySet restricted to assets at index i.
Related
source