Expected Returns: private API
PortfolioOptimisers.PerfRM — Type
const PerfRM = Union{<:MeanReturn, <:MeanReturnRiskRatio, <:ExpectedReturn,
<:ExpectedReturnRiskRatio}Union of performance risk measures used to compute portfolio performance metrics (returns and return/risk ratios).
The group exists because every one of its members reports a performance figure rather than a loss, so a larger value is a better one. bigger_is_better dispatches on this alias and answers true for all four in one method, which is the whole reason the four are grouped.
Related
MeanReturn: reads a realised return series.MeanReturnRiskRatio: reads a realised return series.ExpectedReturn: reads a prior result, so it is also aPrRM.ExpectedReturnRiskRatio: reads a prior result, so it is also aPrRM.PrRM: the two members of this group that read a prior result.bigger_is_better: the method that dispatches on this alias.
PortfolioOptimisers.PrRM — Type
const PrRM = Union{<:ExpectedReturn, <:ExpectedReturnRiskRatio}Union of prior-based return risk measures that are incompatible with PredictionResult inputs and require the use of MeanReturn or MeanReturnRiskRatio instead.
The group exists because both members read the prior result itself rather than a returns matrix, so neither declares a risk_input_kind. That one property drives every method that dispatches on the alias: the vector-of-weights route resolves the measure once and keeps the prior in hand, the prediction-result routes refuse the call, and supports_precomputed_returns answers false.
Related
ExpectedReturnExpectedReturnRiskRatioPerfRM: the wider group both members also belong to.prrm_prediction_message: builds the refusal the prediction-result methods raise.risk_input_kind: the declaration neither member makes.
PortfolioOptimisers.supports_precomputed_returns — Method
supports_precomputed_returns(
_::Union{ExpectedReturn, ExpectedReturnRiskRatio}
) -> Bool
Return false: a PrRM never supports precomputed returns.
Both members read the prior result and contract the expected returns it states with the portfolio weights. A bare net-return series carries neither the expected returns nor the weights, so r(x::VecNum) is undefined for the two types and neither defines one. The predicate answers here rather than reaching the erroring default of risk_input_kind, which reads to a caller as an internal fault rather than as a statement about the measure they chose.
To score a bare return series, name MeanReturn or MeanReturnRiskRatio instead, which is the substitution prrm_prediction_message names for the prediction-result routes.
Related
PrRMsupports_precomputed_returnsrisk_input_kind: the declaration neither member makes.MeanReturn: theNetReturnsInputmeasure that does score a bare series.expected_risk_from_returns: the contract entry this predicate gates.
PortfolioOptimisers.term_fees — Function
term_fees(
w::AbstractVector{<:Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}},
_::Nothing,
_::Number,
_::Bool
) -> Any
Charge the fees to a return term only when that term's settings.fee says so.
The scalar twin follows the fee flag alone. Market impact is absent from expected_return on either side of the multiplicity, so this preserves a pre-existing divergence between the model expression and its scalar twin rather than widening one.
Arguments
w: Portfolio weights.fees: Optional fees.T: Observation count of the fit, over which the one-off terms are spread.fee: The term'ssettings.feeflag.
Returns
f::Number: The per period charge,calc_periodic_feespluscalc_one_off_feesdivided byT, whenfeeistrue, and a zero of the element type ofwotherwise.
Related
PortfolioOptimisers.sric_penalty — Function
sric_penalty(sr::Number, pr::AbstractPriorResult) -> Any
Compute the estimation-error penalty that turns a ratio into a SRIC.
The penalty is applied once to the aggregate ratio, never per element. This 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 delegate here rather than restate the ratio.
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 supplies $T$ and $N$.
Returns
p::Number: The estimation-error penalty.
Related
PortfolioOptimisers.prrm_prediction_message — Function
prrm_prediction_message(
r::Union{ExpectedReturn, ExpectedReturnRiskRatio},
pred
) -> String
Build the refusal a PrRM raises on a prediction result.
The refusal itself is about prior versus realised returns, and multiplicity does not touch it: a PrRM reads a prior result, and a prediction result carries a realised series instead.
The suggested replacement does depend on multiplicity. MeanReturn carries no return estimator, so it cannot hold the several terms a widened rt holds. When rt is a vector the message says so, rather than telling the caller that a lossy substitution is equivalent.
Algorithm
- Choose the replacement measure
altfrom the kind ofr:MeanReturnfor anExpectedReturn, andMeanReturnRiskRatiofor anExpectedReturnRiskRatio. - Write the first sentence of
msg, namingr, the wrapper type ofpredandalt. - When the
rtofris a vector, append the second sentence, naming the number of terms it holds and the two routes that keep them.
Arguments
r: The measure that refuses the call.pred: The prediction result the caller supplied.
Returns
msg::String: The message of theArgumentErrorthe refusing methods raise.
Related
PrRMMeanReturnMeanReturnRiskRatioexpected_risk: the four methods that raise this message.