Expected returns

PortfolioOptimisers.ExpectedReturn — Type
struct ExpectedReturn{__T_settings, __T_rt} <: NonOptimisationRiskMeasure

Risk measure whose value is the expected portfolio return of a prior result.

ExpectedReturn is a NonOptimisationRiskMeasure, so an optimiser cannot use it as an objective or as a constraint. Use it where a function takes a risk measure and the figure must be the expected return. For example, it is the default y axis of plot_measures and of plot_efficient_frontier. A larger value is a better value, as PerfRM states.

Mathematical definition

\[\begin{align} \mathrm{ER}(\boldsymbol{w}) &= \sum_{j \,:\, e_{j}} s_j\, R_j(\boldsymbol{w})\,. \end{align}\]

Where:

  • $\mathrm{ER}(\boldsymbol{w})$: Expected portfolio return, the value of the measure.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $R_j$: Expected return of the $j$-th term in rt, net of fees.
  • $s_j$: settings.scale of the $j$-th term. A single rt has one term.
  • $e_j$: settings.rte of the $j$-th term. The sum runs over the terms whose flag is true.

Fields

  • settings: Risk measure settings.
  • rt: Return estimator, or a vector of them. The measure sums a vector at the settings.scale weights of its terms, and it skips a term whose settings.rte is false. The return axis has no scalariser.

Constructors

ExpectedReturn(;    settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),    rt::JRE_VecJRE = ArithmeticReturn()) -> ExpectedReturn

Keywords correspond to the struct's fields.

Multiplicity

rt takes one return term or a vector of them, so ExpectedReturn(; rt = res.ret) works after a solve with many terms. The measure sums a vector at the settings.scale weights of its terms, and it skips a term whose settings.rte is false.

The type has no scalariser. The return axis sums and never scalarises.

Validation

  • If rt is a vector: !isempty(rt).

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • rt: Recursively updated through factory.

Examples

julia> ExpectedReturn()ExpectedReturn  settings ┼ HierarchicalRiskMeasureSettings           │   scale ┴ Float64: 1.0        rt ┼ ArithmeticReturn           │   settings ┼ JuMPReturnsSettings           │            │   scale ┼ Float64: 1.0           │            │      lb ┼ nothing           │            │     rte ┼ Bool: true           │            │     fee ┼ Bool: true           │            │     mic ┴ Bool: true           │        ucs ┼ nothing           │         mu ┼ nothing           │   mtx_sqrt ┴ EigenFallbackSquareRoot()

Related

source
PortfolioOptimisers.ExpectedReturnRiskRatio — Type
struct ExpectedReturnRiskRatio{__T_settings, __T_rt, __T_rk, __T_sca, __T_rf} <: NonOptimisationRiskMeasure

Risk measure whose value is the ratio of the expected return of a portfolio to its expected risk.

ExpectedReturnRiskRatio holds a return estimator, a risk measure and a risk-free rate. Its value is the risk-adjusted return ratio of expected_ratio, for example the Sharpe ratio when rk is a StandardDeviation. It is a NonOptimisationRiskMeasure, so an optimiser cannot use it as an objective or as a constraint. A larger value is a better value, as PerfRM states.

Mathematical definition

\[\begin{align} \mathrm{ERRR}(\boldsymbol{w}) &= \frac{\sum_{j \,:\, e_{j}} s_j\, R_j(\boldsymbol{w}) - r_f}{\mathrm{sca}\left(\left\{c_i\, \rho_i(\boldsymbol{w})\right\}\right)}\,. \end{align}\]

Where:

  • $\mathrm{ERRR}(\boldsymbol{w})$: Expected return to risk ratio.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $R_j$: Expected return of the $j$-th term in rt, net of fees.
  • $s_j$: settings.scale of the $j$-th term of rt.
  • $e_j$: settings.rte of the $j$-th term of rt. The sum runs over the terms whose flag is true.
  • $r_f$: Risk-free rate, the rf field.
  • $\rho_i$: The $i$-th risk measure in rk.
  • $c_i$: settings.scale of the $i$-th risk measure.
  • $\mathrm{sca}$: Scalariser held in sca, which reduces the risk axis to one number.

Fields

  • settings: Risk measure settings.
  • rt: Return estimator, or a vector of them. The measure sums a vector at the settings.scale weights of its terms, and it skips a term whose settings.rte is false. The return axis has no scalariser.
  • rk: Risk measure for ratio computation, or a vector of them scalarised by sca.
  • sca: Scalariser combining the risk measures in rk into one number. nothing gives the sum of SumScalariser. Inert when rk holds a single measure. The field beats a sca keyword supplied at the call site.
  • rf: Risk-free rate.

Constructors

ExpectedReturnRiskRatio(;    settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),    rt::JRE_VecJRE = ArithmeticReturn(),    rk::BaseRM_VecBaseRM = Variance(),    sca::Option{<:Scalariser} = nothing,    rf::Number = 0.0,) -> ExpectedReturnRiskRatio

Keywords correspond to the struct's fields.

Multiplicity

Each axis takes one item or a vector of items, and only the risk axis has a scalariser. rt sums its terms at their settings.scale weights, and it skips a term whose settings.rte is false. sca scalarises rk into one number. Then the ratio divides one aggregate by the other. The return axis sums and never scalarises.

The field takes precedence over a sca keyword of the caller. A sca that the caller gives at the call site goes no further than this type. So the figure of an ExpectedReturnRiskRatio is always the figure that the type names.

Validation

  • If rt is a vector: !isempty(rt).
  • If rk is a vector: !isempty(rk).
  • isfinite(rf).

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • rt: Recursively updated through factory.
  • rk: Recursively updated through factory.

Examples

julia> ExpectedReturnRiskRatio()ExpectedReturnRiskRatio  settings ┼ HierarchicalRiskMeasureSettings           │   scale ┴ Float64: 1.0        rt ┼ ArithmeticReturn           │   settings ┼ JuMPReturnsSettings           │            │   scale ┼ Float64: 1.0           │            │      lb ┼ nothing           │            │     rte ┼ Bool: true           │            │     fee ┼ Bool: true           │            │     mic ┴ Bool: true           │        ucs ┼ nothing           │         mu ┼ nothing           │   mtx_sqrt ┴ EigenFallbackSquareRoot()        rk ┼ Variance           │    settings ┼ RiskMeasureSettings           │             │   scale ┼ Float64: 1.0           │             │      ub ┼ nothing           │             │     rke ┴ Bool: true           │       sigma ┼ nothing           │        chol ┼ nothing           │          rc ┼ nothing           │         alg ┼ SquaredSOCRiskExpr()           │    mtx_sqrt ┼ EigenFallbackSquareRoot()           │   ratio_alg ┼ SquareRootRatio()           │      corner ┴ nothing       sca ┼ nothing        rf ┴ Float64: 0.0

Related

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

Compute the value of an ExpectedReturn, the expected return of a portfolio.

The method calls expected_return on the rt field of the measure. ExpectedReturn states the closed form.

The measure also has a route on a returns matrix. It declares WeightsReturnsFeesInput, and its functor r(w, X, fees) calls resolved_expected_return on rt. That route needs the mu of an rt that factory resolved, and the prior route of risk_contribution, risk_gradient and of each composite measure gives it. Both routes read one ladder, so they give the same value.

Arguments

  • r: ExpectedReturn that holds a return estimator.
  • w: Portfolio weights.
  • pr: Prior result.
  • fees: Optional transaction fees.
  • kwargs...: Keyword arguments that go to expected_return, strict included.

Returns

  • risk::Number: Expected portfolio return, net of fees when they are given.

Related

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

Compute the value of an ExpectedReturnRiskRatio, the risk-adjusted return ratio of a portfolio.

The method calls expected_ratio with the fields of the measure. ExpectedReturnRiskRatio states the closed form.

The call puts kwargs... first and the sca and rf fields of the measure after it. So the fields take precedence over a sca or an rf that the caller gives at the call site. The figure of an ExpectedReturnRiskRatio is always the figure that the type names.

The measure is also a composite on a returns matrix, as MeanReturnRiskRatio is. Its methods of expected_risk, worst_case_distribution and linearised_risk on X::MatNum divide resolved_expected_return of rt, minus rf, by the risk of rk. They need an rt that factory resolved, and the prior route of risk_contribution, risk_gradient and of each composite measure gives it. A weight path, w::MatNum, throws an ArgumentError.

Arguments

  • r: ExpectedReturnRiskRatio that holds a return estimator, a risk measure and a risk-free rate.
  • w: Portfolio weights.
  • pr: Prior result.
  • fees: Optional transaction fees.
  • kwargs...: Keyword arguments that go to expected_ratio, strict included. A sca or an rf among them has no effect.

Returns

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

Related

source
PortfolioOptimisers.expected_risk — Method
expected_risk(::Option{<:Scalariser}, r::PrRM,
              pred::PredictionResult{<:PredictionReturnsResult{<:Any, <:VecNum}};
              kwargs...)
expected_risk(::Option{<:Scalariser}, r::PrRM,
              pred::PredictionResult{<:PredictionReturnsResult{<:Any, <:VecVecNum}};
              kwargs...)
expected_risk(::Option{<:Scalariser}, r::PrRM, pred::MultiPeriodPredictionResult; kwargs...)
expected_risk(::Option{<:Scalariser}, r::PrRM, pred::PopulationPredictionResult; kwargs...)

Refuse to compute a risk measure that reads a prior on a prediction result.

A PrRM reads a prior result. It multiplies the expected returns of the prior by the weights. A prediction result holds a realised return series and no expected returns, so the two measures have nothing to read. Each of the four methods raises an error, and none gives a figure from the wrong input.

The four methods are positional forms, which take the scalariser first and ignore it. The keyword form expected_risk(r, pred; kwargs...) of a prediction calls them, so both forms raise the error.

The caller has two routes:

Arguments

  • ::Option{<:Scalariser}: The scalariser of the call, which none of the four methods reads.
  • r: ExpectedReturn or ExpectedReturnRiskRatio.
  • pred: The prediction result that the caller gave.
  • kwargs...: Keyword arguments that none of the four methods reads.

Validation

  • Every method raises an ArgumentError, with the message that prrm_prediction_message builds. No method returns for any input.

Related

source
PortfolioOptimisers.expected_return — Function
expected_return(ret::ArithmeticReturn, w::VecNum, pr::AbstractPriorResult,
                fees::Option{<:Fees} = nothing; strict::Bool = false, kwargs...)
expected_return(ret::LogarithmicReturn, w::VecNum, pr::AbstractPriorResult,
                fees::Option{<:Fees} = nothing; strict::Bool = false, kwargs...)
expected_return(ret::NoReturn, w::VecNum, pr::AbstractPriorResult,
                fees::Option{<:Fees} = nothing; kwargs...)
expected_return(ret::JRE_VecJRE, w::VecVecNum, pr::AbstractPriorResult,
                fees::Option{<:Fees} = nothing; strict::Bool = false, kwargs...)

Compute the expected return of a portfolio with a return estimator.

expected_return reads the portfolio weights, a prior result and optional transaction fees. fees is a positional argument after pr on every method.

The prior route reduces to the Investable Mask. A prior result holds every asset of the universe, and an asset that it cannot estimate carries NaN in mu and down its column of pr.X. On the whole universe, dot(w, mu) and X * w are NaN at every weight, a zero weight included. So each method reduces the prior, the weights and the fees once at its entry, through investable_reduction. An optimiser does the same reduction at its entry. NoReturn gives zero at every weight, so it reads nothing and reduces nothing.

The reduction changes nothing on a prior that is already reduced. The moments of a reduced prior are finite everywhere, so investable_mask gives nothing. Thus a vector of terms, a population and a composite such as expected_ratio each give one diagnostic only.

Each method is the scalar twin of the ret expression that set_return_constraints! builds for the same estimator, so the two sides charge the same fee. For a NoReturn, the model builds a zero expression and charges no fee on it. settings.fee has no effect on that term, and the scalar twin charges no fee either.

An ArithmeticReturn whose ucs holds a fitted set gives the worst-case return over the set, ucs_expected_return, in place of $\boldsymbol{w}^{\intercal} \boldsymbol{\mu}$. The model expression of that term is the worst case, so a lower bound on the term holds at w exactly when this value meets it. An estimator in ucs gives the nominal return, because no set exists until an optimiser fits it. The functor of UncertaintySetVariance reads its set by the same rule. The resolved return terms of an optimisation, in the ret of its ResolvedJuMPOptimiser, hold the fitted sets.

The fourth method takes a vector of weight vectors. It applies one of the first three methods to each weight vector, and returns one expected return for each.

Mathematical definition

\[\begin{align} R_{\mathrm{a}}(\boldsymbol{w}) &= \boldsymbol{w}^{\intercal} \boldsymbol{\mu} - F(\boldsymbol{w})\\ R_{\mathrm{l}}(\boldsymbol{w}) &= \dfrac{\sum\limits_{t=1}^{T} v_{t} \ln\left(1 + \boldsymbol{x}_{t}^{\intercal} \boldsymbol{w}\right)}{\sum\limits_{t=1}^{T} v_{t}} - F(\boldsymbol{w})\\ R_{\mathrm{n}}(\boldsymbol{w}) &= 0\,. \end{align}\]

Where:

  • $R_{\mathrm{a}}(\boldsymbol{w})$: Expected return of an ArithmeticReturn.
  • $R_{\mathrm{l}}(\boldsymbol{w})$: Expected return of a LogarithmicReturn, the mean log-growth rate of the portfolio.
  • $R_{\mathrm{n}}(\boldsymbol{w})$: Expected return of a NoReturn. It has no fee term, so it is zero for every value of fees.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $\boldsymbol{\mu}$: Expected returns vector $N \times 1$.
  • $\boldsymbol{x}_t$: Asset returns for observation $t$, the $t$-th row of the returns matrix.
  • $T$: Number of observations.
  • $v_{t}$: Observation weight of observation $t$, the $t$-th entry of the w field of a LogarithmicReturn, or of the observation weights pr.w of the prior when that field is nothing. Every weight is one when both are nothing, and the quotient is then the unweighted mean.
  • $F(\boldsymbol{w})$: Fee term of term_fees. It is calc_fees of w and fees when the term's settings.fee is true, and zero otherwise.

Arguments

  • ret: Return estimator, or a vector of them on the fourth method.
  • w: Portfolio weights, or a vector of portfolio weight vectors on the fourth method.
  • pr: Prior result. It resolves a Deferred Quantity of ret, through factory. It gives mu to an ArithmeticReturn whose own mu is nothing, and its observation weights to a LogarithmicReturn whose own w is nothing.
  • fees: Optional fees.
  • strict: If true, weights that hold an asset outside the Investable Mask raise an ArgumentError that names the assets. If false, a warning names the assets, and the function drops their weights. A NoReturn reads no weights, so strict has no effect on it.
  • kwargs...: Keyword arguments that the methods do not read.

Returns

  • rt::Number: Expected portfolio return, net of fees, on the first three methods.
  • rt::VecNum: One expected portfolio return for each weight vector, on the fourth method.

Related

source
expected_return(
    ret::AbstractVector{<:JuMPReturnsEstimator},
    w::AbstractVector{<:Union{Number, AbstractJuMPScalar}},
    pr::AbstractPriorResult;
    ...
) -> Any
expected_return(
    ret::AbstractVector{<:JuMPReturnsEstimator},
    w::AbstractVector{<:Union{Number, AbstractJuMPScalar}},
    pr::AbstractPriorResult,
    fees::Union{Nothing, Fees};
    strict,
    kwargs...
) -> Any

Sum the value-level returns of many return terms, each at its own scale.

This method is the scalar twin of the ret expression of the model, which is the same weighted sum over the same terms. The method skips a term whose settings.rte is false, and the model skips it too.

The barrier of NearOptimalCentering reads the aggregate return of all the terms as one number, and this method gives that number. expected_ratio and the other value-level functions of this file call this method when ret is a vector.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= \sum_{j \,:\, e_{j}} s_{j} \, R_{j}(\boldsymbol{w})\,. \end{align}\]

Where:

  • $R(\boldsymbol{w})$: Aggregate expected return of the whole vector of terms.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $R_{j}(\boldsymbol{w})$: Expected return of the $j$-th term, net of its own fee.
  • $s_{j}$: settings.scale of the $j$-th term.
  • $e_{j}$: settings.rte of the $j$-th term. The sum runs over the terms whose flag is true.

Algorithm

  1. Reduce the prior, the weights and the fees to the Investable Mask once, with investable_reduction. A held asset outside the mask gives one diagnostic, and not one for each term.
  2. Resolve each term against the prior with factory, as the model does.
  3. Return resolved_expected_return of the resolved terms. It skips each term whose settings.rte is false, and it sums the settings.scale of each other term times its return. The method for one term reads the same function, so the two give the same value.

Arguments

  • ret: Vector of return estimators.
  • w: Portfolio weights.
  • pr: Prior result.
  • fees: Optional fees.
  • strict: If true, weights that hold an asset outside the Investable Mask raise an ArgumentError that names the assets. If false, a warning names the assets, and the function drops their weights.
  • kwargs...: Keyword arguments that the method does not read.

Returns

  • rt::Number: Aggregate expected portfolio return of the terms whose settings.rte is true.

Related

source
PortfolioOptimisers.expected_ratio — Function
expected_ratio(r::BaseRM_VecBaseRM, ret::JRE_VecJRE, w::VecNum,
               pr::AbstractPriorResult, fees::Option{<:Fees} = nothing;
               rf::Number = 0, sca::Option{<:Scalariser} = nothing,
               strict::Bool = false, kwargs...)

Compute the ratio of the expected return of a portfolio to its expected risk.

expected_ratio divides the expected portfolio return, net of the fees and of the risk-free rate, by the expected portfolio risk. The risk measure r gives the risk, and the return estimator ret gives the return.

Mathematical definition

\[\begin{align} \mathrm{ratio}(\boldsymbol{w}) &= \dfrac{R(\boldsymbol{w}) - r_{f}}{\mathrm{sca}\left(\left\{c_{i}\, \rho_{i}(\boldsymbol{w})\right\}\right)}\,. \end{align}\]

Where:

  • $\mathrm{ratio}(\boldsymbol{w})$: Risk-adjusted return ratio.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $R(\boldsymbol{w})$: Aggregate expected return of ret, the sum of its terms at their own settings.scale weights, each net of fees.
  • $r_{f}$: Risk-free rate, the rf keyword.
  • $\rho_{i}$: The $i$-th risk measure in r.
  • $c_{i}$: settings.scale of the $i$-th risk measure.
  • $\mathrm{sca}$: Scalariser held in sca, which reduces the risk axis to one number.

Multiplicity

Each axis takes one item or a vector of items, and the ratio divides one aggregate by the other. sca scalarises the risk axis into one number. The return axis sums at the settings.scale weights of its terms. Then the function divides the two aggregates.

Only the risk axis has a scalariser. The return axis sums and never scalarises.

Resolution

Both axes receive pr itself, so both apply the same precedence rule. A stated slot comes first, then the estimator of the slot, then the field of the prior. The risk axis goes through the prior route of expected_risk. That route resolves the measure through resolve_risk_inputs once for each call. It fits a Deferred Quantity against pr, and an unstated slot takes the field of the prior.

Arguments

  • r: Risk measure, or a vector of them.
  • ret: Return estimator, or a vector of them.
  • w: Portfolio weights.
  • pr: Prior result.
  • fees: Optional transaction fees.
  • rf: Risk-free rate.
  • sca: Scalariser that reduces a vector r to one number. It has no effect on a single measure.
  • strict: If true, weights that hold an asset outside the Investable Mask raise an ArgumentError that names the assets. If false, a warning names the assets, and the function drops their weights.
  • kwargs...: Keyword arguments that go to expected_risk and to expected_return.

Returns

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

Related

source
PortfolioOptimisers.expected_risk_ret_ratio — Function
expected_risk_ret_ratio(r::BaseRM_VecBaseRM, ret::JRE_VecJRE, w::VecNum,
                        pr::AbstractPriorResult, fees::Option{<:Fees} = nothing;
                        rf::Number = 0, sca::Option{<:Scalariser} = nothing,
                        strict::Bool = false, kwargs...)

Compute the expected risk, the expected return and the risk-adjusted return ratio of a portfolio.

expected_risk_ret_ratio returns the three numbers as a tuple. The risk measure r gives the risk, and the return estimator ret gives the return.

Mathematical definition

\[\begin{align} \mathrm{risk}(\boldsymbol{w}) &= \mathrm{sca}\left(\left\{c_{i}\, \rho_{i}(\boldsymbol{w})\right\}\right)\\ \mathrm{return}(\boldsymbol{w}) &= R(\boldsymbol{w})\\ \mathrm{ratio}(\boldsymbol{w}) &= \dfrac{\mathrm{return}(\boldsymbol{w}) - r_{f}}{\mathrm{risk}(\boldsymbol{w})}\,. \end{align}\]

Where:

  • $\mathrm{risk}(\boldsymbol{w})$, $\mathrm{return}(\boldsymbol{w})$, $\mathrm{ratio}(\boldsymbol{w})$: The three entries of the returned tuple, in that order.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $R(\boldsymbol{w})$: Aggregate expected return of ret, the sum of its terms at their own settings.scale weights, each net of fees.
  • $r_{f}$: Risk-free rate, the rf keyword.
  • $\rho_{i}$: The $i$-th risk measure in r.
  • $c_{i}$: settings.scale of the $i$-th risk measure.
  • $\mathrm{sca}$: Scalariser held in sca, which reduces the risk axis to one number.

Multiplicity

The rule is the same as for expected_ratio. Each axis takes one item or a vector of items, and the ratio divides one aggregate by the other. sca scalarises the risk axis into one number, and the return axis sums at the settings.scale weights of its terms. The returned risk and return are those two aggregates. They are never a breakdown for each item.

Only the risk axis has a scalariser. The return axis sums and never scalarises.

The figures of an optimisation result

Use this function to get the figures of an optimisation result. A result holds the measure and the scalariser of its solve, so the call can read them from the result:

rk, rt, rr = expected_risk_ret_ratio(res.r, res.ret, res.w, res.pr; sca = res.sca, rf = rf)

A result stores res.r and res.ret resolved. So this call gives the aggregates that the optimisation optimised, for one item or for many items on each axis. A caller can also name the measures by hand. Then the figure is equal to that of the optimisation only when the caller names the same measures and the same scalariser. The same holds for fees and rf.

A NonRiskJuMPOptimisationResult has no r, because its solve resolved no measure. With such a result, the caller must name a measure.

Arguments

  • r: Risk measure, or a vector of them.
  • ret: Return estimator, or a vector of them.
  • w: Portfolio weights.
  • pr: Prior result.
  • fees: Optional transaction fees.
  • rf: Risk-free rate.
  • sca: Scalariser that reduces a vector r to one number. It has no effect on a single measure.
  • strict: If true, weights that hold an asset outside the Investable Mask raise an ArgumentError that names the assets. If false, a warning names the assets, and the function drops their weights.
  • kwargs...: Keyword arguments that go to expected_risk and to expected_return.

Returns

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

Related

source
PortfolioOptimisers.expected_sric — Function
expected_sric(r::BaseRM_VecBaseRM, ret::JRE_VecJRE, w::VecNum,
              pr::AbstractPriorResult, fees::Option{<:Fees} = nothing;
              rf::Number = 0, sca::Option{<:Scalariser} = nothing,
              strict::Bool = false, kwargs...)

Compute the Sharpe ratio information criterion (SRIC) of a portfolio.

The SRIC corrects the risk-adjusted return ratio for the estimation error of an optimisation, which makes the in-sample ratio too large. expected_sric subtracts from the ratio a penalty that reads the number of assets and the number of observations.

Mathematical definition

\[\begin{align} \mathrm{SRIC}(\boldsymbol{w}) &= \mathrm{ratio}(\boldsymbol{w}) - P\left(\mathrm{ratio}(\boldsymbol{w})\right)\,. \end{align}\]

Where:

  • $\mathrm{SRIC}(\boldsymbol{w})$: Sharpe ratio information criterion.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $\mathrm{ratio}(\boldsymbol{w})$: Risk-adjusted return ratio of expected_ratio, which states its own closed form.
  • $P$: Estimation-error penalty of sric_penalty, which states its own closed form.

Multiplicity

The function penalises the ratio of expected_ratio, so the rule is the same as for that function. The ratio divides one aggregate by the other. sca scalarises the risk axis, and the return axis sums at the settings.scale weights of its terms. The function subtracts the penalty once from the scalar ratio, and not from each item.

Arguments

  • r: Risk measure, or a vector of them.
  • ret: Return estimator, or a vector of them.
  • w: Portfolio weights.
  • pr: Prior result.
  • fees: Optional transaction fees.
  • rf: Risk-free rate.
  • sca: Scalariser that reduces a vector r to one number. It has no effect on a single measure.
  • strict: If true, weights that hold an asset outside the Investable Mask raise an ArgumentError that names the assets. If false, a warning names the assets, and the function drops their weights. The reduction also sets the number of assets of the penalty to the number of assets that the prior can estimate.
  • kwargs...: Keyword arguments that go to expected_ratio.

Returns

  • sric::Number: Sharpe ratio information criterion.

Related

source
PortfolioOptimisers.expected_risk_ret_sric — Function
expected_risk_ret_sric(r::BaseRM_VecBaseRM, ret::JRE_VecJRE, w::VecNum,
                       pr::AbstractPriorResult, fees::Option{<:Fees} = nothing;
                       rf::Number = 0, sca::Option{<:Scalariser} = nothing,
                       strict::Bool = false, kwargs...)

Compute the expected risk, the expected return and the SRIC of a portfolio.

expected_risk_ret_sric returns the three numbers as a tuple. The Sharpe ratio information criterion (SRIC) corrects the risk-adjusted return ratio for estimation error, as expected_sric states.

Mathematical definition

\[\begin{align} \mathrm{SRIC}(\boldsymbol{w}) &= \mathrm{ratio}(\boldsymbol{w}) - P\left(\mathrm{ratio}(\boldsymbol{w})\right)\,. \end{align}\]

Where:

  • $\mathrm{SRIC}(\boldsymbol{w})$: Sharpe ratio information criterion, the third entry of the returned tuple. The first two entries are those of expected_risk_ret_ratio, which states their closed forms.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $\mathrm{ratio}(\boldsymbol{w})$: Risk-adjusted return ratio of expected_risk_ret_ratio.
  • $P$: Estimation-error penalty of sric_penalty, which states its own closed form.

Multiplicity

The tuple is the tuple of expected_risk_ret_ratio, with the penalty subtracted from its third entry. So the rule is the same as for that function, and the ratio divides one aggregate by the other. The returned risk and return are the two aggregates, and never a breakdown for each item. The function subtracts the penalty once from the scalar ratio.

Arguments

  • r: Risk measure, or a vector of them.
  • ret: Return estimator, or a vector of them.
  • w: Portfolio weights.
  • pr: Prior result. Its returns matrix X gives the two counts of the penalty.
  • fees: Optional transaction fees.
  • rf: Risk-free rate. It defaults to 0.
  • sca: Scalariser that reduces a vector r to one number. It has no effect on a single measure.
  • strict: If true, weights that hold an asset outside the Investable Mask raise an ArgumentError that names the assets. If false, a warning names the assets, and the function drops their weights.
  • kwargs...: Keyword arguments that go to expected_risk_ret_ratio.

Returns

  • risk::Number: Expected portfolio risk.
  • return::Number: Expected portfolio return.
  • sric::Number: Sharpe ratio information criterion.

Related

source
PortfolioOptimisers.factory — Method
factory(a, args...; kwargs...) -> a
factory(a::AbstractArray{<:Union{Nothing, AbstractEstimator, AbstractAlgorithm,
                                 AbstractResult, StatsBase.CovarianceEstimator}},
        args...; kwargs...) -> AbstractArray

Rebuild an estimator, an algorithm or a result with runtime values. These two methods are the leaf and the array step of the traversal.

factory and port_opt_view are the two propagation mechanisms of this library. factory passes runtime values, such as prior moments, observation weights and previous portfolio weights, down a tree of composed structs. port_opt_view passes an index selection, a subset of the assets, down the same tree.

factory is a traversal, so it owns the identity on every leaf, as fmap in Functors.jl and adapt_structure in Adapt.jl do. A value that has no method of its own comes back with no change: a data field, a scalar, nothing, a set of observation weights and a covariance estimator of StatsBase. So a @propagatable struct sends each @fprop field to factory directly, whatever the field holds.

The array method is the one forwarding contract for every propagation field that holds an array of estimators, algorithms, results or covariance estimators. It applies factory to each element, and it forwards args... and kwargs... with no change. A family that accepts an array of them needs no method of its own. A family that needs more than the forward defines its own, more specific method. A concrete element type, through concrete_typed_array_if_abstract, is an example. An array of data, such as a vector of numbers, is a leaf, and it comes back with no change and with no copy.

Algorithm

The leaf method:

  1. Return a with no change, and drop args... and kwargs.... This method is the leaf of the recursion. Because of it, a call of the verb on a type with no tags returns the value and raises no error.

The array method:

  1. For each element ai of a, call factory on ai, and forward args... and kwargs... with no change.
  2. Collect the results into a new array of the shape of a, in the order of a, and return it.

A @propagatable struct always has a generated method that is more specific than the leaf method. If the struct has at least one @fprop or @wprop field, that method builds the struct again with its keyword constructor. It sends each @fprop field through factory and each @wprop field through _wprop. If the struct has no such field, that method returns x.

The leaf method does not fill a nothing field. A weights field that must take the incoming weights when it holds nothing carries @wprop, and it goes to _wprop.

Arguments

  • a: Any value, which the leaf method returns with no change. For the array method, an array of estimators, algorithms, results, covariance estimators or nothing, which it rebuilds one element at a time.
  • args...: Positional arguments. The leaf method ignores them, and the array method forwards them.
  • kwargs...: Keyword arguments. The leaf method ignores them, and the array method forwards them.

Returns

  • a: The input with no change, for the leaf method.
  • v::AbstractArray: The rebuilt elements, in an array of the shape of a, for the array method.

Examples

julia> factory(nothing, 1, 2; x = 3)julia> factory([1.0, 2.0], 1, 2; x = 3)2-element Vector{Float64}: 1.0 2.0julia> factory(MeanValue())MeanValue  w ┴ nothing

Related

source
PortfolioOptimisers.factory — Method
factory(a, args...; kwargs...) -> a
factory(a::AbstractArray{<:Union{Nothing, AbstractEstimator, AbstractAlgorithm,
                                 AbstractResult, StatsBase.CovarianceEstimator}},
        args...; kwargs...) -> AbstractArray

Rebuild an estimator, an algorithm or a result with runtime values. These two methods are the leaf and the array step of the traversal.

factory and port_opt_view are the two propagation mechanisms of this library. factory passes runtime values, such as prior moments, observation weights and previous portfolio weights, down a tree of composed structs. port_opt_view passes an index selection, a subset of the assets, down the same tree.

factory is a traversal, so it owns the identity on every leaf, as fmap in Functors.jl and adapt_structure in Adapt.jl do. A value that has no method of its own comes back with no change: a data field, a scalar, nothing, a set of observation weights and a covariance estimator of StatsBase. So a @propagatable struct sends each @fprop field to factory directly, whatever the field holds.

The array method is the one forwarding contract for every propagation field that holds an array of estimators, algorithms, results or covariance estimators. It applies factory to each element, and it forwards args... and kwargs... with no change. A family that accepts an array of them needs no method of its own. A family that needs more than the forward defines its own, more specific method. A concrete element type, through concrete_typed_array_if_abstract, is an example. An array of data, such as a vector of numbers, is a leaf, and it comes back with no change and with no copy.

Algorithm

The leaf method:

  1. Return a with no change, and drop args... and kwargs.... This method is the leaf of the recursion. Because of it, a call of the verb on a type with no tags returns the value and raises no error.

The array method:

  1. For each element ai of a, call factory on ai, and forward args... and kwargs... with no change.
  2. Collect the results into a new array of the shape of a, in the order of a, and return it.

A @propagatable struct always has a generated method that is more specific than the leaf method. If the struct has at least one @fprop or @wprop field, that method builds the struct again with its keyword constructor. It sends each @fprop field through factory and each @wprop field through _wprop. If the struct has no such field, that method returns x.

The leaf method does not fill a nothing field. A weights field that must take the incoming weights when it holds nothing carries @wprop, and it goes to _wprop.

Arguments

  • a: Any value, which the leaf method returns with no change. For the array method, an array of estimators, algorithms, results, covariance estimators or nothing, which it rebuilds one element at a time.
  • args...: Positional arguments. The leaf method ignores them, and the array method forwards them.
  • kwargs...: Keyword arguments. The leaf method ignores them, and the array method forwards them.

Returns

  • a: The input with no change, for the leaf method.
  • v::AbstractArray: The rebuilt elements, in an array of the shape of a, for the array method.

Examples

julia> factory(nothing, 1, 2; x = 3)julia> factory([1.0, 2.0], 1, 2; x = 3)2-element Vector{Float64}: 1.0 2.0julia> factory(MeanValue())MeanValue  w ┴ nothing

Related

source
PortfolioOptimisers.needs_previous_weights — Method
needs_previous_weights(r::AbstractBaseRiskMeasure) -> Bool
needs_previous_weights(r::VecBaseRM) -> Bool

Return whether risk measure r requires previous portfolio weights as input.

The default returns false. Override to true for risk measures such as turnover or tracking constraints that depend on prior weights. The VecBaseRM overload returns true if any element returns true.

Returns

  • Bool: true if prior weights are required; false otherwise.

Related

source
needs_previous_weights(x::Any) -> Bool
needs_previous_weights(x::AbstractVector) -> Bool

Return true if an entry of a TimeDependent vector reads the weights of the previous fold.

A turnover, a fee, a tracking input, a risk measure, a budget cost, an optimisation estimator or result, a constraint and a nested schedule each give their own method. A vector gives true if any of its elements does. Every other value, such as a number or a bare function, gives false, because no code can find out what a bare function reads.

Related

source
needs_previous_weights(
    _::Union{Nothing, AbstractAlgorithm, AbstractEstimator, AbstractResult}
) -> Any

Returns false, the fallback for nothing and for every estimator, algorithm and result that has no method of its own.

A type whose value reads the weights of the previous fold adds a method that returns true, for example a turnover, a tracking error or a fee.

Related

source
PortfolioOptimisers.supports_precomputed_returns — Method
supports_precomputed_returns(
    _::Union{ExpectedReturn, ExpectedReturnRiskRatio}
) -> Bool

Return false, because a PrRM does not support precomputed returns.

Both members read the portfolio weights and the prior through their return estimator: an ArithmeticReturn multiplies the expected returns of the prior by the weights, and a LogarithmicReturn weights each observation by the observation weights of the prior and charges the fee of the weights once, after the mean. A bare series of net returns holds neither the prior nor the weights. So neither type defines r(x::VecNum), and expected_risk_from_returns refuses both with a message that names the cause.

To score a bare return series, use MeanReturn or MeanReturnRiskRatio. prrm_prediction_message names the same replacement for a prediction result.

Related

source