Non-Optimisation Risk Measures
PortfolioOptimisers.MeanReturn Type
struct MeanReturn{__T_w, __T_flag} <: NonOptimisationRiskMeasureRepresents a simple mean return measure for use in non-optimisation contexts.
MeanReturn computes the arithmetic (or geometric, when flag = true) mean of portfolio returns. It is used as the numerator in risk-adjusted performance ratios such as MeanReturnRiskRatio.
Mathematical definition
For flag = false (arithmetic mean):
Where:
: Arithmetic mean portfolio return. : Portfolio returns vector . : Number of observations.
For flag = true (log-return mean):
Where:
: Log-return mean portfolio return. : Portfolio returns vector . : Number of observations.
For observation-weighted samples, the weighted mean is used instead.
Fields
w: Optional portfolio weights.flag: Algorithm selection flag.
Constructors
MeanReturn(;
w::Option{<:ObsWeights} = nothing,
flag::Bool = false
) -> MeanReturnKeywords correspond to the struct's fields.
Validation
- If
wis notnothing:!isempty(w).
Functor
(r::MeanReturn)(x::VecNum)Computes the mean return of a portfolio returns vector x.
Arguments
x::VecNum: Portfolio returns vector.
Examples
julia> MeanReturn()
MeanReturn
w ┼ nothing
flag ┴ Bool: falseRelated
sourcePortfolioOptimisers.factory Method
factory(
r::MeanReturn,
pr::AbstractPriorResult,
args...
) -> MeanReturn{_A, Bool} where _ACreate an instance of MeanReturn by selecting observation weights from the risk-measure instance or falling back to the prior result.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(r::MeanReturn, _, args...) -> MeanReturnReturn the MeanReturn risk measure r unchanged.
MeanReturn does not have asset-level parameters to slice.
Related
sourcePortfolioOptimisers.MeanReturnRiskRatio Type
struct MeanReturnRiskRatio{__T_rt, __T_rk, __T_rf} <: NonOptimisationRiskMeasureRepresents a mean return to risk ratio measure.
MeanReturnRiskRatio computes the ratio of the mean portfolio return (minus a risk-free rate) to a risk measure, used for performance analysis and comparison. It generalises the Sharpe ratio by allowing any risk measure in the denominator.
Mathematical definition
Where:
: Mean return to risk ratio. : Portfolio returns vector . : Mean portfolio return (computed by rt).: Risk-free rate. : Base risk measure (computed by rk).
Fields
rt: Mean return estimator.rk: Risk measure for ratio computation.rf: Risk-free rate.
Constructors
MeanReturnRiskRatio(;
rt::MeanReturn = MeanReturn(),
rk::AbstractBaseRiskMeasure = ConditionalValueatRisk(),
rf::Number = 0.0
) -> MeanReturnRiskRatioKeywords correspond to the struct's fields.
Related
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(r::MeanReturnRiskRatio) -> AnyReturn whether MeanReturnRiskRatio r requires previous portfolio weights.
Delegates to the inner risk measure r.rk.
Related
sourcePortfolioOptimisers.factory Method
factory(
r::MeanReturnRiskRatio,
args...;
kwargs...
) -> MeanReturnRiskRatio{MeanReturn{__T_w, __T_flag}, <:AbstractBaseRiskMeasure, <:Number} where {__T_w, __T_flag}Create an instance of MeanReturnRiskRatio by updating both the return measure and risk measure from the optimisation context.
Related
sourcePortfolioOptimisers.factory Method
factory(
r::MeanReturnRiskRatio,
w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}
) -> MeanReturnRiskRatio{MeanReturn{__T_w, __T_flag}, <:AbstractBaseRiskMeasure, <:Number} where {__T_w, __T_flag}Create an instance of MeanReturnRiskRatio updating the risk measure from new portfolio weights w.
The return measure rt is preserved unchanged.
Related
sourcePortfolioOptimisers.ThirdCentralMoment Type
struct ThirdCentralMoment{__T_w, __T_mu} <: NonOptimisationRiskMeasureRepresents the Third Central Moment risk measure.
ThirdCentralMoment computes the third central moment of portfolio returns about a specified centre. It is used as a measure of the asymmetry (skewness) of the return distribution in higher-order portfolio optimisation.
Mathematical definition
Let
Where:
: Third central moment of portfolio returns. : Portfolio returns vector . : Number of observations. : Specified centre of the distribution. : Centred deviation at period .
For observation-weighted samples, the weighted mean is used.
Fields
w: Optional portfolio weights.mu: Optional mean for centering.
Constructors
ThirdCentralMoment(;
w::Option{<:ObsWeights} = nothing,
mu::Option{<:Num_VecNum_VecScalar} = nothing
) -> ThirdCentralMomentKeywords correspond to the struct's fields.
Validation
If
muis aVecNum:!isempty(mu).If
wis notnothing:!isempty(w).
Functor
(r::ThirdCentralMoment)(w::VecNum, X::MatNum, fees = nothing)Computes the third central moment of the portfolio returns.
Arguments
w::VecNum: Portfolio weights vector.X::MatNum: Asset returns matrix (). fees: Optional fee structure.
Examples
julia> ThirdCentralMoment()
ThirdCentralMoment
w ┼ nothing
mu ┴ nothingRelated
sourcePortfolioOptimisers.factory Method
factory(
r::ThirdCentralMoment,
pr::AbstractPriorResult,
args...;
kwargs...
) -> ThirdCentralMomentCreate an instance of ThirdCentralMoment by selecting observation weights and expected returns from the risk-measure instance or falling back to the prior result.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
r::ThirdCentralMoment,
i,
args...
) -> ThirdCentralMomentReturn a view of ThirdCentralMoment r sliced to asset indices i.
Slices the expected returns mu for cluster-based optimisation.
Related
sourcePortfolioOptimisers.TCM_Sk Type
const TCM_Sk{T1, T2} = Union{<:ThirdCentralMoment{T1, T2}, <:Skewness{<:Any, <:Any, T1, T2}}Parameterised union of ThirdCentralMoment and Skewness sharing the same observation-weight (T1) and target-mean (T2) type parameters.
Used for unified dispatch on moment-target calculation methods.
Related
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(::TCM_Sk{Nothing, Nothing}, ::Any, x::VecNum)
calc_moment_target(r::TCM_Sk{<:StatsBase.AbstractWeights, Nothing}, ::Any, x::VecNum)
calc_moment_target(r::TCM_Sk{<:Any, <:VecNum}, w::VecNum, ::Any)
calc_moment_target(r::TCM_Sk{<:Any, <:VecScalar}, w::VecNum, ::Any)
calc_moment_target(r::TCM_Sk{<:Any, <:Number}, ::Any, ::Any)Compute the centering target for ThirdCentralMoment and Skewness risk measures.
Dispatches on the observation-weight type T1 and mean type T2 of TCM_Sk:
No weights, no mu: arithmetic mean of
x.AbstractWeights, no mu: weighted mean ofx.VecNummu: dot product. VecScalarmu:. Numbermu: the scalarr.mudirectly.
Related
sourcePortfolioOptimisers.calc_deviations_vec Function
calc_deviations_vec(
r::Union{ThirdCentralMoment{T1, T2}, Skewness{<:Any, <:Any, <:Any, T1, T2}} where {T1, T2},
w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}
) -> Any
calc_deviations_vec(
r::Union{ThirdCentralMoment{T1, T2}, Skewness{<:Any, <:Any, <:Any, T1, T2}} where {T1, T2},
w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
fees::Union{Nothing, Fees}
) -> AnyCompute the vector of deviations from the centering target for ThirdCentralMoment and Skewness risk measures.
Related
sourcePortfolioOptimisers.calc_deviations_vec Method
calc_deviations_vec(
r::Union{ThirdCentralMoment{T1, T2}, Skewness{<:Any, <:Any, <:Any, T1, T2}} where {T1, T2},
x::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}
) -> AnyCompute the vector of deviations from the centering target for a precomputed returns series for ThirdCentralMoment and Skewness risk measures.
Single-argument form used by the precomputed-returns functor r(x::VecNum) (ADR 0007).
Related
sourcePortfolioOptimisers.supports_precomputed_returns Method
supports_precomputed_returns(r::ThirdCentralMoment) -> AnyReturn whether ThirdCentralMoment r supports precomputed-return evaluation.
Delegates to weight_independent_target on r.mu: true iff the target is Nothing, a Number, or a MedianCenteringFunction; false for per-asset targets.
Related
source