Median Absolute Deviation Risk
PortfolioOptimisers.MedianCenteringFunction Type
abstract type MedianCenteringFunction <: AbstractAlgorithmAbstract supertype for centering functions used in the Median Absolute Deviation risk measure.
Related Types
sourcePortfolioOptimisers.MedianCentering Type
struct MedianCentering <: MedianCenteringFunctionCentres the returns series using the (weighted) median before computing the Median Absolute Deviation.
Related Types
sourcePortfolioOptimisers.MeanCentering Type
struct MeanCentering <: MedianCenteringFunctionCentres the returns series using the (weighted) mean before computing the Median Absolute Deviation.
Related Types
sourcePortfolioOptimisers.MedAbsDevMu Type
const MedAbsDevMu = Union{<:Num_VecNum_VecScalar, <:MedianCenteringFunction}Union of valid centring-target types for MedianAbsoluteDeviation.
Accepts a numeric scalar/vector target or a MedianCenteringFunction (e.g. mean or median centering).
Related
sourcePortfolioOptimisers.MedianAbsoluteDeviation Type
struct MedianAbsoluteDeviation{__T_settings, __T_w, __T_mu, __T_flag} <: HierarchicalRiskMeasureRepresents the Median Absolute Deviation (MAD) risk measure for hierarchical portfolio optimisation.
MedianAbsoluteDeviation computes the median (or mean) absolute deviation of portfolio returns about a specified centre, providing a robust alternative to variance for measuring dispersion.
Mathematical definition
Let
Where:
: Median absolute deviation of portfolio returns. : Portfolio returns vector . : Number of observations. : Chosen centre (median, mean, or user-supplied value). : Deviation of return at period from the centre.
When flag = true (default), the result is scaled by a consistency factor
Fields
settings: Risk measure settings.w: Optional portfolio weights.mu: Optional mean for centering.flag: Algorithm selection flag.
Constructors
MedianAbsoluteDeviation(;
settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),
w::Option{<:ObsWeights} = nothing,
mu::MedAbsDevMu = MedianCentering(),
flag::Bool = true
) -> MedianAbsoluteDeviationKeywords correspond to the struct's fields.
Validation
If
muis aVecNum:!isempty(mu)andall(isfinite, mu).If
muis aNumber:isfinite(mu).If
wis notnothing:!isempty(w).
Functor
(r::MedianAbsoluteDeviation)(w::VecNum, X::MatNum, fees = nothing)Computes the MAD of the portfolio returns series.
Arguments
w::VecNum: Portfolio weights vector.X::MatNum: Asset returns matrix (). fees: Optional fee structure.
Examples
julia> MedianAbsoluteDeviation()
MedianAbsoluteDeviation
settings ┼ HierarchicalRiskMeasureSettings
│ scale ┴ Float64: 1.0
w ┼ nothing
mu ┼ MedianCentering()
flag ┴ Bool: trueRelated
sourcePortfolioOptimisers.factory Method
factory(
r::MedianAbsoluteDeviation,
pr::AbstractPriorResult,
args...;
kwargs...
) -> MedianAbsoluteDeviation{__T_settings, __T_w, __T_mu, Bool} where {__T_settings, __T_w, __T_mu}Create an instance of MedianAbsoluteDeviation by selecting observation weights from the risk-measure instance or falling back to the prior result.
Related
sourcePortfolioOptimisers.nothing_scalar_array_view Method
nothing_scalar_array_view(
x::MedianCenteringFunction,
_
) -> MedianCenteringFunctionReturn the MedianCenteringFunction x unchanged.
Identity pass-through: centering functions are not sliced by asset index.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
r::MedianAbsoluteDeviation,
i,
args...
) -> MedianAbsoluteDeviation{HierarchicalRiskMeasureSettings{__T_scale}, _A, _B, Bool} where {__T_scale, _A, _B}Return a view of MedianAbsoluteDeviation r sliced to asset indices i.
Slices the centering target mu for cluster-based optimisation.
Related
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(::MedianAbsoluteDeviation{<:Any, Nothing, <:MeanCentering, ...}, ::Any, x::VecNum)
calc_moment_target(r::MedianAbsoluteDeviation{<:Any, <:ObsWeights, <:MeanCentering, ...}, ::Any, x::VecNum)
calc_moment_target(::MedianAbsoluteDeviation{<:Any, Nothing, <:MedianCentering, ...}, ::Any, x::VecNum)
calc_moment_target(r::MedianAbsoluteDeviation{<:Any, <:ObsWeights, <:MedianCentering, ...}, ::Any, x::VecNum)
calc_moment_target(r::MedianAbsoluteDeviation{<:Any, <:Any, <:VecNum, ...}, w::VecNum, ::Any)
calc_moment_target(r::MedianAbsoluteDeviation{<:Any, <:Any, <:Number, ...}, ::Any, ::Any)
calc_moment_target(r::MedianAbsoluteDeviation{<:Any, <:Any, <:VecScalar, ...}, w::VecNum, ::Any)Compute the centering target for MedianAbsoluteDeviation risk measure calculations.
Dispatches on the type of r.w and r.mu:
No weights +
MeanCentering: arithmetic mean ofx.ObsWeights+MeanCentering: weighted mean ofx.No weights +
MedianCentering: median ofx.ObsWeights+MedianCentering: weighted median ofx.VecNummu: dot product. Numbermu: the scalarr.mudirectly.VecScalarmu:.
Related
sourcePortfolioOptimisers.calc_deviations_vec Function
calc_deviations_vec(
r::MedianAbsoluteDeviation,
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::MedianAbsoluteDeviation,
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 MedianAbsoluteDeviation risk measures.
Related
sourcePortfolioOptimisers.calc_deviations_vec Method
calc_deviations_vec(
r::MedianAbsoluteDeviation,
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 MedianAbsoluteDeviation.
Single-argument form used by the precomputed-returns functor r(x::VecNum) (ADR 0007).
Related
sourcePortfolioOptimisers.weight_independent_target Method
weight_independent_target(
_::MedianCenteringFunction
) -> BoolReturn true: MedianCenteringFunction targets are weight-independent centering functions and can be evaluated on a bare return series.
Related
sourcePortfolioOptimisers.supports_precomputed_returns Method
supports_precomputed_returns(
r::MedianAbsoluteDeviation
) -> AnyReturn whether MedianAbsoluteDeviation 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