Skip to content
13

Expected Risk

PortfolioOptimisers.MatNum_Pr Type
julia
const MatNum_Pr = Union{<:MatNum, <:AbstractPriorResult, <:ReturnsResult}

Union of matrix-like types accepted as the data argument in risk_contribution and related functions.

Related

source
PortfolioOptimisers.ERkNetRet Type
julia
const ERkNetRet = Union{...}

Union of risk measures whose expected risk is computed on net returns (returns after fees).

These risk measures receive the net-returns vector calc_net_returns(w, X, fees) as their sole argument.

Related

source
PortfolioOptimisers.ERkwXFees Type
julia
const ERkwXFees = Union{...}

Union of risk measures whose expected risk depends on both weights, returns matrix, and fees.

These risk measures are called as r(w, X, fees).

Related

source
PortfolioOptimisers.ERkX Type
julia
const ERkX = Union{<:ERkNetRet, <:ERkwXFees}

Union of all risk measures that require the returns matrix X (and optionally fees) for expected risk computation.

Related

source
PortfolioOptimisers.ERkw Type
julia
const ERkw = Union{...}

Union of risk measures whose expected risk depends only on portfolio weights.

These risk measures are called as r(w).

Related

source
PortfolioOptimisers.TnTrRM Type
julia
const TnTrRM = Union{<:TurnoverRiskMeasure, <:TrRM}

Union of turnover and tracking risk measures used to update previous-weight dependent factories.

Related

source
PortfolioOptimisers.SlvRM Type
julia
const SlvRM = Union{...}

Union of solver-based risk measures (entropic and relativistic families) that require an iterative solver for expected risk computation.

Related

source
PortfolioOptimisers.RkRatioRM Type
julia
const RkRatioRM = Union{<:RiskRatioRiskMeasure, <:NonOptimisationRiskRatioRiskMeasure}

Union of all risk-ratio risk measures, where the expected risk is defined as the ratio of two component risk values.

Related

source
PortfolioOptimisers.expected_risk Function
julia
expected_risk(r::ExpectedReturn, w::VecNum, pr::AbstractPriorResult;
              fees::Option{<:Fees} = nothing, kwargs...)

Compute the expected risk for a portfolio using a return-based risk measure.

expected_risk returns the expected portfolio return as the risk metric, using the specified return estimator in the ExpectedReturn. This is useful for algorithms where risk is defined as expected return.

Arguments

  • r: ExpectedReturn containing a return estimator.

  • w: Portfolio weights.

  • pr: Prior result.

  • fees: Optional transaction fees.

  • kwargs...: Additional keyword arguments.

Returns

  • risk::Number: Expected portfolio return (net of fees if provided).

Related

source
julia
expected_risk(r::ExpectedReturnRiskRatio, w::VecNum, pr::AbstractPriorResult;
              fees::Option{<:Fees} = nothing, kwargs...)

Compute the expected risk for a portfolio using a ratio-based risk measure.

expected_risk returns the risk-adjusted return ratio (e.g., Sharpe ratio) for the portfolio, using the specified return estimator, risk measure, and risk-free rate in the ExpectedReturnRiskRatio.

Arguments

  • r: ExpectedReturnRiskRatio containing a return estimator, risk measure, and risk-free rate.

  • w: Portfolio weights.

  • pr: Prior result.

  • fees: Optional transaction fees.

  • kwargs...: Additional keyword arguments.

Returns

  • risk::Number: Risk-adjusted return ratio.

Related

source
PortfolioOptimisers.number_effective_assets Function
julia
number_effective_assets(w::VecNum)

Compute the effective number of assets (Herfindahl-Hirschman inverse index):

Neff=1iwi2

Returns the number of equally-weighted assets that would produce the same level of concentration as the given weight vector w.

Arguments

  • w::VecNum: Portfolio weight vector.

Returns

  • Number: Effective number of assets.

Related

source
PortfolioOptimisers.risk_contribution Function
julia
risk_contribution(
    r::AbstractBaseRiskMeasure,
    w::VecNum,
    X::MatNum_Pr,
    fees::Option{<:Fees} = nothing;
    delta::Number = 1e-6,
    marginal::Bool = false,
    kwargs...
) -> Vector

Compute the risk contribution of each asset to the total portfolio risk using numerical differentiation.

The risk contribution of asset i is defined as:

RCi=wiρ(w)wi,

where the partial derivative is approximated by a two-sided finite difference with step size delta. When marginal = true, the weighting by wi is omitted (i.e., only the marginal risk ρ/wi is returned).

Arguments

  • r::AbstractBaseRiskMeasure: Risk measure to differentiate.

  • w::VecNum: Portfolio weights vector.

  • X::MatNum_Pr: Asset returns matrix or prior result.

  • fees::Option{<:Fees}: Optional fee structure.

Keyword Arguments

  • delta::Number = 1e-6: Finite difference step size.

  • marginal::Bool = false: If true, returns marginal risk contributions (without wi weighting).

Returns

  • Vector: Risk contributions (or marginal risks) for each asset.

Related

source
PortfolioOptimisers.factor_risk_contribution Function
julia
factor_risk_contribution(
    r::AbstractBaseRiskMeasure,
    w::VecNum,
    X::MatNum_Pr,
    fees::Option{<:Fees} = nothing;
    re::RegE_Reg = StepwiseRegression(),
    rd::ReturnsResult = ReturnsResult(),
    delta::Number = 1e-6,
    kwargs...
) -> Vector

Compute the risk contribution of each factor (and the idiosyncratic component) to the total portfolio risk using a factor regression.

The factor risk contributions partition total portfolio risk into factor-specific components using the Brinson attribution framework:

FRCk=(Bw)k(Bρ)k,

where B is the factor loading matrix estimated by regression.

Arguments

  • r::AbstractBaseRiskMeasure: Risk measure to decompose.

  • w::VecNum: Portfolio weights vector.

  • X::MatNum_Pr: Asset returns matrix or prior result.

  • fees::Option{<:Fees}: Optional fee structure.

Keyword Arguments

  • re::RegE_Reg = StepwiseRegression(): Regression estimator for factor loadings.

  • rd::ReturnsResult = ReturnsResult(): Returns result providing factor data.

  • delta::Number = 1e-6: Finite difference step size.

Returns

  • Vector: Risk contributions for each factor, with the last element being the idiosyncratic (off-factor) contribution.

Related

source