Variance
PortfolioOptimisers.QuadRiskExpr Type
struct QuadRiskExpr <: VarianceFormulation endDirect quadratic risk expression optimisation formulation for variance-like risk measures. The risk measure is implemented using an explicitly quadratic form. This can be in two ways.
Summary statistics
Where:
: N×1asset weights vector.: N×Nco-moment matrix.
Scenario-based
Where:
: N×1asset weights vector.: T×1deviations vector.: Scenario set for portfolio x.
Related Types
sourcePortfolioOptimisers.SquaredSOCRiskExpr Type
struct SquaredSOCRiskExpr <: VarianceFormulation endSquared second-order cone risk expression optimisation formulation for applicable risk measures. The risk measure is implemented using the square of a variable constrained by a second order cone.
Related
sourcePortfolioOptimisers.RSOCRiskExpr Type
struct RSOCRiskExpr <: SecondMomentFormulation endRotated second-order cone risk expression optimisation formulation for applicable risk measures. The risk measure using a variable constrained to be in a rotated second order cone representing the sum of squares.
Related Types
sourcePortfolioOptimisers.SOCRiskExpr Type
struct SOCRiskExpr <: SecondMomentFormulation endSecond-order cone risk expression optimisation formulation for applicable risk measures. The risk measure is implemented using a variable constrained by a second order cone.
Related
sourcePortfolioOptimisers.Variance Type
struct Variance{T1, T2, T3, T4} <: RiskMeasure
settings::T1
sigma::T2
rc::T3
alg::T4
endRepresents the portfolio variance using a covariance matrix.
Fields
settings: Risk measure configuration.sigma: Optional covariance matrix that overrides the prior covariance when provided. Also used to compute the risk represented by a vector.rc: Optional specification of risk contribution constraints.alg: The optimisation formulation used to represent the variance risk expression.
Constructors
Variance(; settings::RiskMeasureSettings = RiskMeasureSettings(),
sigma::Union{Nothing, <:AbstractMatrix} = nothing,
rc::Union{Nothing, <:LinearConstraintEstimator, <:LinearConstraint} = nothing,
alg::VarianceFormulation = SquaredSOCRiskExpr())Keyword arguments correspond to the fields above.
Validation
- If
sigmais provided,!isempty(sigma)andsize(sigma, 1) == size(sigma, 2).
JuMP Formulations
Info
Regardless of the formulation used, an auxiliary variable representing the standard deviation is needed in order to constrain the risk or maximise the risk-adjusted return ratio. This is because quadratic constraints are not strictly convex, and the transformation needed to maximise the risk-adjusted return ratio requires affine variables in the numerator and denominator.
Depending on the alg field, the variance risk measure is formulated using JuMP as follows:
QuadRiskExpr
Where:
: N×1asset weights vector.: N×Ncovariance matrix.
SquaredSOCRiskExpr
Where:
: N×1asset weights vector.: Variable representing the optimised portfolio's standard deviation. : Suitable factorisation of the N×Ncovariance matrix, such as the square root matrix, or the Cholesky factorisation.: L2 norm, which is modelled as a SecondOrderCone.
Functor
(r::Variance)(w::AbstractVector)Computes the variance risk of a portfolio with weights w using the covariance matrix r.sigma.
Where:
: N×1asset weights vector.: N×Ncovariance matrix.
Arguments
w::AbstractVector: Asset weights.
Examples
julia> w = [0.3803452066954233, 0.5900852659955864, 0.029569527308990307];
julia> r = Variance(;
sigma = [0.97780 -0.06400 0.84818;
-0.06400 3.28564 1.84588;
0.84818 1.84588 2.16317])
Variance
settings ┼ RiskMeasureSettings
│ scale ┼ Float64: 1.0
│ ub ┼ nothing
│ rke ┴ Bool: true
sigma ┼ 3×3 Matrix{Float64}
rc ┼ nothing
alg ┴ SquaredSOCRiskExpr()
julia> r(w)
1.3421705804186579Related
sourcePortfolioOptimisers.StandardDeviation Type
struct StandardDeviation{T1, T2} <: RiskMeasure
settings::T1
sigma::T2
endRepresents the portfolio standard deviation using a covariance matrix. It is the square root of the variance.
Fields
settings: Risk measure configuration.sigma: Optional covariance matrix that overrides the prior covariance when provided. Also used to compute the risk represented by a vector.
Constructors
StandardDeviation(; settings::RiskMeasureSettings = RiskMeasureSettings(),
sigma::Union{Nothing, <:AbstractMatrix} = nothing)Keyword arguments correspond to the fields above.
Validation
- If
sigmais provided,!isempty(sigma)andsize(sigma, 1) == size(sigma, 2).
JuMP Formulation
Where:
: N×1asset weights vector.: Variable representing the optimised portfolio's standard deviation. : Suitable factorisation of the N×Ncovariance matrix, such as the square root matrix, or the Cholesky factorisation.: L2 norm, which is modelled as a SecondOrderCone.
Functor
(r::StandardDeviation)(w::AbstractVector)Computes the standard deviation risk of a portfolio with weights w using the covariance matrix r.sigma.
Where:
: N×1asset weights vector.: N×Ncovariance matrix.
Arguments
w::AbstractVector: Asset weights.
Examples
julia> w = [0.3803452066954233, 0.5900852659955864, 0.029569527308990307];
julia> r = StandardDeviation(;
sigma = [0.97780 -0.06400 0.84818;
-0.06400 3.28564 1.84588;
0.84818 1.84588 2.16317])
StandardDeviation
settings ┼ RiskMeasureSettings
│ scale ┼ Float64: 1.0
│ ub ┼ nothing
│ rke ┴ Bool: true
sigma ┴ 3×3 Matrix{Float64}
julia> r(w)
1.1585208588621345Related
sourcePortfolioOptimisers.UncertaintySetVariance Type
struct UncertaintySetVariance{T1, T2, T3} <: RiskMeasureRepresents the variance risk measure under uncertainty sets. Works the same way as the Variance risk measure but allows specifying uncertainty set estimators or results. These are only used in JuMP-based optimisations because they dictate how the variance is formulated as an optimisation problem. By encapsulating the uncertainty set estimator or result, enables the use of multiple uncertainty set variances in the same optimisation model.
Fields
settings: Risk measure configuration.ucs: Uncertainty set estimator or result that defines the uncertainty model for the variance calculation.sigma: Optional covariance matrix that overrides the prior covariance when provided. Also used to compute the risk represented by a vector.
Constructors
UncertaintySetVariance(; settings::RiskMeasureSettings = RiskMeasureSettings(),
ucs::Union{Nothing, <:AbstractUncertaintySetResult,
<:AbstractUncertaintySetEstimator} = NormalUncertaintySet(),
sigma::Union{Nothing, <:AbstractMatrix{<:Real}} = nothing)Keyword arguments correspond to the fields above.
Validation
- If
sigmais provided,!isempty(sigma).
JuMP Formulations
When using an uncertainty set on the variance, the optimisation problem becomes:
Where:
: N×1asset weights vector.: N×Ncovariance matrix.: Uncertainty set for the covariance matrix.
This problem can be reformulated depending on the type of uncertainty set used.
Box uncertainty set
Where:
: N×1asset weights vector., , : N×Nauxiliary symmetric matrices.: N×Nlower bound of the covariance matrix.: N×Nupper bound of the covariance matrix.: Scalar variable/constant. If the objective risk-adjusted return, it is a non-negative variable.
Else it is equal to 1.
: Trace operator.
Ellipse uncertainty set
Where:
: N×1asset weights vector.: N×Ncovariance matrix., : N×Nauxiliary symmetric matrices.: Scalar constant defining the size of the uncertainty set. : Variable representing the portfolio's variance of the variance. : Suitable factorisation of the N^2×N^2covariance of the covariance matrix of the uncertainty set, such as the square root matrix, or the Cholesky factorisation.: Scalar variable/constant. If the objective risk-adjusted return, it is a non-negative variable.
Else it is equal to 1.
: Trace operator. : Vectorisation operator, which unrolls a matrix as a column vector in column-major order. : L2 norm, which is modelled as a SecondOrderCone.
Functor
(r::UncertaintySetVariance)(w::AbstractVector)Computes the variance risk of a portfolio with weights w using the covariance matrix r.sigma.
Where:
: N×1asset weights vector.: N×Ncovariance matrix.
Arguments
w::AbstractVector: Asset weights.
Examples
julia> w = [0.3803452066954233, 0.5900852659955864, 0.029569527308990307];
julia> r = UncertaintySetVariance(;
sigma = [0.97780 -0.06400 0.84818;
-0.06400 3.28564 1.84588;
0.84818 1.84588 2.16317])
UncertaintySetVariance
settings ┼ RiskMeasureSettings
│ scale ┼ Float64: 1.0
│ ub ┼ nothing
│ rke ┴ Bool: true
ucs ┼ NormalUncertaintySet
│ pe ┼ EmpiricalPrior
│ │ ce ┼ PortfolioOptimisersCovariance
│ │ │ ce ┼ Covariance
│ │ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ │ w ┴ nothing
│ │ │ │ ce ┼ GeneralCovariance
│ │ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ │ w ┴ nothing
│ │ │ │ alg ┴ Full()
│ │ │ mp ┼ DefaultMatrixProcessing
│ │ │ │ pdm ┼ Posdef
│ │ │ │ │ alg ┴ UnionAll: NearestCorrelationMatrix.Newton
│ │ │ │ denoise ┼ nothing
│ │ │ │ detone ┼ nothing
│ │ │ │ alg ┴ nothing
│ │ me ┼ SimpleExpectedReturns
│ │ │ w ┴ nothing
│ │ horizon ┴ nothing
│ alg ┼ BoxUncertaintySetAlgorithm()
│ n_sim ┼ Int64: 3000
│ q ┼ Float64: 0.05
│ rng ┼ Random.TaskLocalRNG: Random.TaskLocalRNG()
│ seed ┴ nothing
sigma ┴ 3×3 Matrix{Float64}
julia> r(w)
1.3421705804186579Related
sourcePortfolioOptimisers.factory Method
factory(r::Variance, prior::AbstractPriorResult, args...; kwargs...)Create an instance of Variance by selecting the covariance matrix from the risk-measure instance or falling back to the prior result (see nothing_scalar_array_factory).
Arguments
r: Prototype risk measure whosesettings,rcandalgfields are reused for the new instance.prior: Prior result providingprior.sigmato use whenr.sigma === nothing.args...: Extra positional arguments are accepted for API compatibility but are ignored by this constructor.kwargs...: Keyword arguments are accepted for API compatibility but are ignored by this constructor.
Returns
r_new::Variance: A newVarianceinstance.
Details
Selects
sigmausingnothing_scalar_array_factory.Other fields are taken from
r.
Related
sourcePortfolioOptimisers.factory Method
factory(r::StandardDeviation, prior::AbstractPriorResult, args...; kwargs...)Create an instance of StandardDeviation by selecting the covariance matrix from the risk-measure instance or falling back to the prior result (see nothing_scalar_array_factory).
Arguments
r: Prototype risk measure whosesettings,rcandalgfields are reused for the new instance.prior: Prior result providingprior.sigmato use whenr.sigma === nothing.args...: Extra positional arguments are accepted for API compatibility but are ignored by this constructor.kwargs...: Keyword arguments are accepted for API compatibility but are ignored by this constructor.
Returns
r_new::StandardDeviation: A newStandardDeviationinstance.
Details
Selects
sigmausingnothing_scalar_array_factory.Other fields are taken from
r.
Related
sourcePortfolioOptimisers.factory Function
factory(r::UncertaintySetVariance, prior::AbstractPriorResult, ::Any,
ucs::Union{Nothing, <:AbstractUncertaintySetResult,
<:AbstractUncertaintySetEstimator} = nothing, args...;
kwargs...)Create an instance of UncertaintySetVariance by selecting the uncertainty set and covariance matrix from the risk-measure instance or falling back to the prior result.
Arguments
r: Prototype risk measure whosesettingsandsigmafields are reused for the new instance.prior: Prior result providingprior.sigmato use whenr.sigma === nothing.::Any: Placeholder positional argument for API compatibility.ucs: Optional uncertainty set estimator or result to overrider.ucs.args...: Extra positional arguments are accepted for API compatibility but are ignored by this constructor.kwargs...: Keyword arguments are accepted for API compatibility but are ignored by this constructor.
Returns
r_new::UncertaintySetVariance: A newUncertaintySetVarianceinstance.
Details
Selects
ucsusingucs_factory.Selects
sigmausingnothing_scalar_array_factory.Other fields are taken from
r.
Related
PortfolioOptimisers.SecondMomentFormulation Type
abstract type SecondMomentFormulation <: AbstractAlgorithm endAbstract supertype for optimisation formulations of second moment risk measures in PortfolioOptimisers.jl.
Related Types
sourcePortfolioOptimisers.VarianceFormulation Type
abstract type VarianceFormulation <: SecondMomentFormulation endAbstract supertype for optimisation formulations of variance-based risk measures in PortfolioOptimisers.jl.
Related Types
source