Expected returns: private API

PortfolioOptimisers.PerfRM — Type
const PerfRM = Union{MeanReturn, MeanReturnRiskRatio, ExpectedReturn,
                     ExpectedReturnRiskRatio}

Union of the risk measures whose value is a performance figure, a return or a ratio of return to risk.

Each member gives a performance figure and not a loss, so a larger value is a better value. bigger_is_better dispatches on this alias and gives true for the four members in one method. That method is the only reason for the group.

Related

source
PortfolioOptimisers.PrRM — Type
const PrRM = Union{ExpectedReturn, ExpectedReturnRiskRatio}

Union of the return risk measures that read a prior result, and that refuse a PredictionResult. On a prediction result, use MeanReturn or MeanReturnRiskRatio in their place.

Both members read the prior result through their return estimator, which a return series does not hold: an ArithmeticReturn reads the expected returns mu, and a LogarithmicReturn reads the observation weights. The factory of the risk path fills them into the return estimator of the measure, so the resolved measure reads the weights, the returns matrix and the fees. ExpectedReturn declares WeightsReturnsFeesInput, and ExpectedReturnRiskRatio is a composite with methods of its own, as MeanReturnRiskRatio is. Thus risk_contribution, risk_gradient and every composite of the risk path take both members. Each method that dispatches on the alias follows from the need for a prior:

Related

source
PortfolioOptimisers.term_fees — Function
term_fees(
    w::AbstractVector{<:Union{Number, AbstractJuMPScalar}},
    _::Nothing,
    _::Number,
    _::Bool
) -> Any

Charge the fees to a return term when the settings.fee of the term is true.

The scalar twin reads the fee flag only. When settings.mic is true, the model expression also subtracts a market impact cost, through add_market_impact_cost!. No method of expected_return charges that cost, for one term or for a vector of terms. So the model expression and its scalar twin differ by the market impact cost, and this function does not change that difference.

Arguments

  • w: Portfolio weights.
  • fees: Optional fees.
  • T: Number of observations of the fit. The function spreads the one-off fees over them.
  • fee: The settings.fee flag of the term.

Returns

  • f::Number: The charge for one period. It is calc_periodic_fees plus calc_one_off_fees divided by T when fee is true. It is a zero of the element type of w when fee is false or fees is nothing.

Related

source
PortfolioOptimisers.sric_penalty — Function
sric_penalty(sr::Number, pr::AbstractPriorResult) -> Any

Compute the estimation-error penalty that changes a ratio into a SRIC.

The SRIC functions subtract the penalty once from the aggregate ratio, and never from each item. The penalty is the only difference between expected_sric and expected_ratio, and between expected_risk_ret_sric and expected_risk_ret_ratio. So both SRIC functions call this function, and they do not state the ratio again.

Mathematical definition

\[\begin{align} P(\mathrm{sr}) &= \dfrac{N}{T \, \mathrm{sr}}\,. \end{align}\]

Where:

  • $P(\mathrm{sr})$: Estimation-error penalty of the ratio $\mathrm{sr}$.
  • $\mathrm{sr}$: Aggregate risk-adjusted return ratio to penalise.
  • $T$: Number of observations.
  • $N$: Number of assets.

Arguments

  • sr: Aggregate risk-adjusted return ratio.
  • pr: Prior result. Its returns matrix gives $T$ and $N$.

Returns

  • p::Number: The estimation-error penalty.

Related

source
PortfolioOptimisers.prrm_prediction_message — Function
prrm_prediction_message(
    r::Union{ExpectedReturn, ExpectedReturnRiskRatio},
    pred
) -> String

Build the message of the error that a PrRM raises on a prediction result.

The refusal is about prior returns and realised returns, and the number of return terms does not change it. A PrRM reads a prior result, and a prediction result holds a realised series.

The replacement that the message names does change with the number of terms. MeanReturn holds no return estimator, so it cannot hold the many terms of a vector rt. When rt is a vector, the message says so. It does not tell the caller that the replacement gives the same figure, because the replacement loses the terms.

Algorithm

  1. Choose the replacement measure alt from the type of r. It is MeanReturn for an ExpectedReturn, and MeanReturnRiskRatio for an ExpectedReturnRiskRatio.
  2. Write the first sentence of msg. It names r, the wrapper type of pred and alt.
  3. When the rt of r is a vector, add the second sentence. It names the number of terms in rt and the two routes that keep them.

Arguments

  • r: The measure that refuses the call.
  • pred: The prediction result that the caller gave.

Returns

  • msg::String: The message of the ArgumentError that the four methods for a prediction result raise.

Related

source
PortfolioOptimisers.reader_frames — Method
reader_frames(r::Union{ExpectedReturn, ExpectedReturnRiskRatio}, path::AbstractString,
              refit::Bool) -> ReturnsFrames

Return the frames of the readers in a risk measure that holds a return term, for the frame walk of a head.

The return term rt can hold an uncertainty set with a prior of its own, as ArithmeticReturn states. The risk side rk of an ExpectedReturnRiskRatio can hold a risk measure with a reader. Each of those readers belongs to the group of the head that holds the measure. So the method reads every field of r with field_frames. A field that holds no reader adds no frame.

Arguments

  • r: The risk measure.
  • path: The path of the value from the head, for example "pe", "cle" or "r[2].pe". A warning names a reader by its path.
  • refit: true when a regression reader at x_src = nothing in the group fits its regression on the raw returns data. refits_regression finds the value.

Returns

  • fr::ReturnsFrames: The frames of the fields of r.

Related

source