Base Uncertainty Sets
PortfolioOptimisers.BoxUncertaintySet Type
struct BoxUncertaintySet{T1, T2} <: AbstractUncertaintySetResult
lb::T1
ub::T2
endRepresents 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.
Fields
lb: Lower bound array for the uncertainty set.ub: Upper bound array for the uncertainty set.
Constructor
BoxUncertaintySet(; lb::AbstractArray, ub::AbstractArray)Keyword arguments correspond to the fields above.
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 <: AbstractUncertaintySetAlgorithm endAlgorithm 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.MuEllipseUncertaintySet Type
struct MuEllipseUncertaintySet <: AbstractEllipseUncertaintySetResultClass endRepresents the class identifier for mean ellipse uncertainty sets in portfolio optimisation.
Used to distinguish ellipse uncertainty sets that encode uncertainty for mean statistics, such as expected returns.
Related Types
sourcePortfolioOptimisers.SigmaEllipseUncertaintySet Type
struct SigmaEllipseUncertaintySet <: AbstractEllipseUncertaintySetResultClass endRepresents the class identifier for covariance ellipse uncertainty sets in portfolio optimisation.
Used to distinguish ellipse uncertainty sets that encode uncertainty for covariance statistics, such as covariance matrices.
Related Types
sourcePortfolioOptimisers.NormalKUncertaintyAlgorithm Type
struct NormalKUncertaintyAlgorithm{T1} <: AbstractUncertaintyKAlgorithm
kwargs::T1
endAlgorithm for computing the scaling parameter k for ellipse uncertainty sets under the assumption of normally distributed returns in portfolio optimisation.
Fields
kwargs: Named tuple of keyword arguments for quantile calculation.
Constructor
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 <: AbstractUncertaintyKAlgorithm endAlgorithm for computing the scaling parameter k for ellipse uncertainty sets using a general formula sqrt((1 - q) / q), this ignores the distribution of the underlying data.
Related Types
sourcePortfolioOptimisers.ChiSqKUncertaintyAlgorithm Type
struct ChiSqKUncertaintyAlgorithm <: AbstractUncertaintyKAlgorithm endAlgorithm for computing the scaling parameter k for ellipse uncertainty sets using the chi-squared distribution in portfolio optimisation.
Related Types
sourcePortfolioOptimisers.EllipseUncertaintySet Type
struct EllipseUncertaintySet{T1, T2, T3} <: AbstractUncertaintySetResult
sigma::T1
k::T2
class::T3
endRepresents an ellipse 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.
Fields
sigma: Covariance matrix for the uncertainty set.k: Scaling parameter for the ellipse.class: Identifier for the type of ellipse uncertainty set (e.g., mean or covariance).
Constructor
EllipseUncertaintySet(; sigma::AbstractMatrix, k::Real,
class::AbstractEllipseUncertaintySetResultClass)Keyword arguments correspond to the fields above.
Validation
!isempty(sigma).size(sigma, 1) == size(sigma, 2).k > 0.
Examples
julia> EllipseUncertaintySet([1.0 0.2; 0.2 1.0], 2.5, SigmaEllipseUncertaintySet())
EllipseUncertaintySet
sigma ┼ 2×2 Matrix{Float64}
k ┼ Float64: 2.5
class ┴ SigmaEllipseUncertaintySet()Related
sourcePortfolioOptimisers.EllipseUncertaintySetAlgorithm Type
struct EllipseUncertaintySetAlgorithm{T1, T2} <: AbstractUncertaintySetAlgorithm
method::T1
diagonal::T2
endAlgorithm for constructing ellipse uncertainty sets in portfolio optimisation. Ellipse 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 ellipse.diagonal: Indicates whether to use only the diagonal elements of the covariance matrix.
Constructor
EllipseUncertaintySetAlgorithm(;
method::Union{<:AbstractUncertaintyKAlgorithm, <:Real} = ChiSqKUncertaintyAlgorithm(),
diagonal::Bool = true)method: Sets the scaling algorithm or value for the ellipse.diagonal: Sets whether to use only diagonal elements.
Examples
julia> EllipseUncertaintySetAlgorithm()
EllipseUncertaintySetAlgorithm
method ┼ ChiSqKUncertaintyAlgorithm()
diagonal ┴ Bool: trueRelated
PortfolioOptimisers.ucs Method
ucs(uc::Union{Nothing,
<:Tuple{<:Union{Nothing, <:AbstractUncertaintySetResult},
<:Union{Nothing, <:AbstractUncertaintySetResult}}}, args...; kwargs...)Returns the argument(s) unchanged. This is a no-op function used to handle cases where no uncertainty sets, or a tuple of pre-processed sets is provided.
Arguments
uc: Tuple of uncertainty sets, ornothing.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
uc::Union{Nothing, <:Tuple{<:Union{Nothing, <:AbstractUncertaintySetResult}, <:Union{Nothing, <: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::Union{Nothing, <:AbstractUncertaintySetResult}, args...; kwargs...)Returns the argument unchanged. This is a no-op function used to handle cases where no expected returns uncertainty set is provided.
Arguments
uc: Expected returns uncertainty set ornothing.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
uc::Union{Nothing, <: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::Union{Nothing, <:AbstractUncertaintySetResult}, args...; kwargs...)Returns the argument unchanged. This is a no-op function used to handle cases where no covariance uncertainty set is provided.
Arguments
uc: Covariance uncertainty set ornothing.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
uc::Union{Nothing, <:AbstractUncertaintySetResult}: The input, unchanged.
Related
sourcePortfolioOptimisers.AbstractUncertaintySetEstimator Type
abstract type AbstractUncertaintySetEstimator <: AbstractEstimator endDefines 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 ellipse uncertainty sets.
Related
sourcePortfolioOptimisers.AbstractUncertaintySetAlgorithm Type
abstract type AbstractUncertaintySetAlgorithm <: AbstractAlgorithm endDefines the abstract interface for algorithms that construct uncertainty sets in portfolio optimisation. Subtypes implement specific methods for generating uncertainty sets, such as box or ellipse uncertainty sets, which are used to model uncertainty in risk or prior statistics.
Related
PortfolioOptimisers.AbstractUncertaintySetResult Type
abstract type AbstractUncertaintySetResult <: AbstractResult endAbstract 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 ellipse uncertainty sets. Subtypes store the output of uncertainty set estimation or construction algorithms.
Related
PortfolioOptimisers.AbstractUncertaintyKAlgorithm Type
abstract type AbstractUncertaintyKAlgorithm <: AbstractAlgorithm endDefines the abstract interface for algorithms that compute the scaling parameter k for ellipse 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 Types
sourcePortfolioOptimisers.AbstractEllipseUncertaintySetResultClass Type
abstract type AbstractEllipseUncertaintySetResultClass <: AbstractUncertaintySetResult endDefines the abstract interface for ellipse uncertainty set result classes in portfolio optimisation.
Subtypes of this abstract type represent the class or category of ellipse uncertainty sets, such as those for mean or covariance statistics. Used to distinguish between different types of ellipse uncertainty set results.
Related Types
sourcePortfolioOptimisers.ucs_factory Function
ucs_factory(risk_ucs::Nothing, prior_ucs::Nothing)
ucs_factory(risk_ucs::Union{<:AbstractUncertaintySetResult, <:AbstractUncertaintySetEstimator}, prior_ucs::Any)
ucs_factory(risk_ucs::Nothing, prior_ucs::Union{<:AbstractUncertaintySetResult, <:AbstractUncertaintySetEstimator})Factory 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
nothing: If bothrisk_ucsandprior_ucsarenothing.risk_ucs::Union{<:AbstractUncertaintySetResult, <:AbstractUncertaintySetEstimator}: Ifrisk_ucsis notnothing.prior_ucs::Union{<:AbstractUncertaintySetResult, <:AbstractUncertaintySetEstimator}: Ifrisk_ucsisnothingbutprior_ucsis notnothing.
Related
sourcePortfolioOptimisers.k_ucs Function
k_ucs(km::NormalKUncertaintyAlgorithm, q::Real, X::AbstractMatrix, sigma_X::AbstractMatrix)
k_ucs(::GeneralKUncertaintyAlgorithm, q::Real, args...)
k_ucs(::ChiSqKUncertaintyAlgorithm, q::Real, X::AbstractArray, args...)
k_ucs(type::Real, args...)Computes the scaling parameter k for ellipse 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: Real value for direct scaling.
Returns
k::Real: 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.Real: returns the provided value directly.
Supports multiple dispatch for extensibility.
Related