Score weight bounds
ScoreWeightBounds bounds the magnitude of each weight by a multiple of the score of its asset. The score comes from a risk measure or from an AbstractAssetScorer, such as a PanelFieldScorer of the median traded amount. Each fit scores the assets on its own returns, so a fold of a cross-validation reads only its training rows. The estimator goes in the wb field of an optimiser, and it tightens the static bounds that its own wb field holds.
PortfolioOptimisers.ScoreWeightBounds — Type
struct ScoreWeightBounds{__T_score, __T_val, __T_dval, __T_wb, __T_symmetric, __T_nonfinite} <: AbstractWeightBoundsEstimatorBounds the magnitude of each weight by a multiple of the score of its asset, on the returns of each fit.
weight_bounds_constraints resolves the estimator in each fit. It scores the assets of the fit with asset_scores, multiplies each score by its entry of val, and joins the result with the static bounds of wb. The tighter bound wins at each asset. Each fit reads the scores of its own window, so a fold of a cross-validation reads the scores of its training rows, and the last fit reads the scores of the whole window.
Two common bounds are of this form.
- A participation limit. The score is the median traded amount of the asset,
PanelFieldScorer(; fields = ["adj_close", "adj_volume"]), andval = k / V, whereVis the notional of the portfolio. A position then needs at mostkdays of trade to enter or to leave. - A bound relative to size. The score is the market capitalisation, and
valismdivided by the capitalisation of the universe. No weight is then more thanmtimes the capitalisation weight of its asset.
Mathematical definition
\[\begin{align} c_{i} &= v_{i} s_{i}\,,\\ \max(l_{i},\, -c_{i}) &\leq w_{i} \leq \min(u_{i},\, c_{i})\,. \end{align}\]
Where:
- $s_{i}$: The score of asset $i$ on the returns of the fit.
- $v_{i}$: The entry of
valof asset $i$. - $c_{i}$: The score bound of asset $i$. An asset whose score is not finite takes
nonfinite, or $+\infty$ whennonfiniteisnothing. An infinite $v_{i}$ gives $c_{i} = +\infty$. - $l_{i}$, $u_{i}$: The static bounds of asset $i$ from
wb. - $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
With symmetric = false, the lower side is $l_{i}$ alone.
Fields
score: The risk measure or the Asset Scorer that gives the score of each asset on the returns of the fit, throughasset_scores.
val: The multiple of the score that bounds the magnitude of each weight. A number is one multiple for every asset, and a vector holds one multiple per asset. A pair, a dictionary, a vector of pairs or an algorithmic rule names the multiples by asset or by group, andestimator_to_valresolves them againstsets.
dval: Default value of each entry thatvaldoes not name.
wb: The static weight bounds that the score bound tightens.nothingstates no static bound.
symmetric: Iftrue, the score bounds both sides of the weight,-c <= w <= c. Iffalse, it bounds the upper side alone,w <= c.
nonfinite: The boundcof an asset whose score is not finite.0admits no position in the asset.nothingstates no bound from the score, so onlywbbounds the asset.
Constructors
ScoreWeightBounds(; score::BaseRM_AsSc, val::VectorEstValType = 1, dval::Option{<:Number} = nothing, wb::Option{<:WbE_Wb} = WeightBounds(), symmetric::Bool = true, nonfinite::Option{<:Number} = 0) -> ScoreWeightBoundsKeywords correspond to the struct's fields. An asset that a pair, a dictionary or a vector of pairs in val does not name takes dval, or one(datatype) when dval is nothing.
Validation
scorecan score one asset, throughassert_scoreable. AnArgumentErroris thrown otherwise.valis not empty, finite and non-negative, throughassert_nonempty_nonneg_finite_val. AnIsEmptyErroror aDomainErroris thrown otherwise. An algorithmic rule is not checked.- If
dvalis notnothing:dval >= 0, throughassert_nonneg. This rule admits+Inf, which gives the assets thatvaldoes not name no bound from the score. ADomainErroris thrown otherwise. - If
nonfiniteis notnothing:nonfinite >= 0, throughassert_nonneg. ADomainErroris thrown otherwise.
A score bound is a magnitude, so the resolution refuses a negative score. The static bounds of wb have no values until the fit, so the resolution also checks them against the score bound. weight_bounds_constraints states both checks.
View parameters
port_opt_view takes the view of these @vprop fields at the selected indices:
val: Sliced to the selected indices throughport_opt_view.wb: Viewed throughport_opt_view.
The view keeps score unchanged. The score reads the returns of the fit, and the fit views them by the same index.
Examples
julia> ScoreWeightBounds(; score = PanelFieldScorer(; fields = "volume"), val = 0.5)ScoreWeightBounds score ┼ PanelFieldScorer │ fields ┼ String: "volume" │ stat ┼ MedianValue │ │ w ┴ nothing │ bib ┼ nothing │ min_obs ┴ Int64: 1 val ┼ Float64: 0.5 dval ┼ nothing wb ┼ WeightBounds │ lb ┼ Float64: 0.0 │ ub ┴ Float64: 1.0 symmetric ┼ Bool: true nonfinite ┴ Int64: 0Related
weight_bounds_constraints documents the resolution of the estimator with its other methods.