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
MeanReturn: It reads a realised return series.MeanReturnRiskRatio: It reads a realised return series.ExpectedReturn: It reads a prior result, so it is also aPrRM.ExpectedReturnRiskRatio: It 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 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:
- The methods for a prediction result refuse the call.
supports_precomputed_returnsgivesfalse.
Related
ExpectedReturnExpectedReturnRiskRatioPerfRM: The larger group that both members also belong to.prrm_prediction_message: It builds the message of the refusal of the prediction-result methods.resolved_expected_return: The return of a resolved estimator on the returns matrix.
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: Thesettings.feeflag of the term.
Returns
f::Number: The charge for one period. It iscalc_periodic_feespluscalc_one_off_feesdivided byTwhenfeeistrue. It is a zero of the element type ofwwhenfeeisfalseorfeesisnothing.
Related
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
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
- Choose the replacement measure
altfrom the type ofr. It isMeanReturnfor anExpectedReturn, andMeanReturnRiskRatiofor anExpectedReturnRiskRatio. - Write the first sentence of
msg. It namesr, the wrapper type ofpredandalt. - When the
rtofris a vector, add the second sentence. It names the number of terms inrtand 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 theArgumentErrorthat the four methods for a prediction result raise.
Related
PrRMMeanReturnMeanReturnRiskRatioexpected_risk: The four methods that raise this message.
PortfolioOptimisers.reader_frames — Method
reader_frames(r::Union{ExpectedReturn, ExpectedReturnRiskRatio}, path::AbstractString,
refit::Bool) -> ReturnsFramesReturn 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:truewhen a regression reader atx_src = nothingin the group fits its regression on the raw returns data.refits_regressionfinds the value.
Returns
fr::ReturnsFrames: The frames of the fields ofr.
Related