Entropy Pooling (c): private API
PortfolioOptimisers.VecEP — Type
const VecEP = AbstractVector{<:Union{<:EntropyPoolingPrior, <:MeucciEntropyPoolingPrior}}Alias for an abstract vector of entropy pooling prior estimators of either family.
Related
PortfolioOptimisers.show_fields — Method
show_fields(_::EntropyPoolingPrior) -> NTuple{15, Symbol}
Renders every field of a EntropyPoolingPrior except cache.
The state a cache holds is the running detail of an incremental fit, not the configuration a reader looks the type up for, and it prints under the estimator at every site that renders one. Set set_show_nothing_fields!(:EntropyPoolingPrior, true) to render it.
Arguments
::EntropyPoolingPrior: Prior estimator, read for its type alone.
Returns
fields::Tuple: The field names to render, which is(:pe, :mu_views, :var_views, :cvar_views, :evar_views, :rlvar_views, :sigma_views, :sk_views, :kt_views, :cov_views, :rho_views, :sets, :opt, :w, :alg).
Related
PortfolioOptimisers.ep_prior — Function
ep_prior(alg::StagedEP, pe::EntropyPoolingPrior, X::MatNum, F::Option{<:MatNum},
pnl::Option{<:AssetPanel} = nothing; strict::Bool = false, kwargs...)Compute entropy pooling prior moments with tail views, enforcing the views in stages.
ep_prior accumulates the views of each stage into one constraint set and solves once per stage, so a stage's views hold alongside every view of the stages before it. The mean of an asset a later stage constrains is pinned to the value the earlier stage produced, so a higher moment view does not silently move it.
Algorithm
- Fit the wrapped prior estimator, giving
pr. The fit states the observation axis:Tissize(pr.X, 1), which a nested prior that drops rows makes smaller thansize(X, 1). - Read the prior probabilities
w0on that axis withep_prior_probabilities. They arepe.wwhere the caller set one,pr.wwhere the fit answered one, and the uniform1/Totherwise. A caller'spe.wreaches the wrapped estimator throughfactory, andpris refitted under it. - Stage one holds the mean, value at risk, conditional, entropic and relativistic value at risk views. Accumulate them into the constraint dictionary
epcand the tail view vectortvs. Where either is non-empty, solve fromw0withentropy_pooling, givingw1, and refitpratw1. - Stage two holds the variance and covariance views, with the mean of every asset they name pinned by
fix_mu!. Whereepcortvsis non-empty, solve fromw0underH1_EntropyPooling, or from the previousw1underH2_EntropyPooling, and refitprat the neww1. - Stage three holds the skewness, kurtosis and correlation views, with the mean and the variance of every asset they name pinned by
fix_mu!andfix_sigma!. Under the same emptiness test, solve from the same start step 4 takes, and refitprat the neww1. - Compute
ens, the effective number of scenarios ofw1, andkld, the divergence ofw1fromw0. - Return a
LowOrderPriorcarrying the refit moments,w1,ensandkld. The feature matrix and the factor block come fromprunchanged.
Every row of every family can drop under strict = false, and a stage then states no view. The emptiness test is on the rows the stages hold, not on the fields the caller set, so such a fit answers the prior: w1 is w0, kld is zero, and no refit runs.
Arguments
alg: Staged entropy pooling algorithm.::H1_EntropyPooling: Each stage re-solves from the original prior weights.::H2_EntropyPooling: Each stage re-solves from the previous stage's weights.
pe: Entropy pooling prior estimator.X: Asset returns matrix, already oriented.F: Optional factor returns matrix, already oriented.pnl: OptionalAssetPanel, the panel the carrier held. A wrapping prior forwards it unchanged, so that it can compose an estimator that is fitted on a panel. An estimator that reads no panel ignores it.strict: Iftrue, throws error for missing assets; otherwise, issue warnings.kwargs...: Additional keyword arguments forwarded to the wrapped prior estimator.
Returns
pr::LowOrderPrior: Prior result carrying the posterior probability weights.
Related
PortfolioOptimisers.ep_prior — Function
ep_prior(alg::H0_EntropyPooling, pe::EntropyPoolingPrior, X::MatNum,
F::Option{<:MatNum}, pnl::Option{<:AssetPanel} = nothing;
strict::Bool = false, kwargs...)Compute entropy pooling prior moments with tail views, enforcing every view in one optimisation.
ep_prior builds every view constraint against the same prior and solves once. It is faster than the staged algorithms and pins nothing, so a higher moment view is free to move a lower moment.
Algorithm
- Fit the wrapped prior estimator, giving
pr. The fit states the observation axis:Tissize(pr.X, 1), which a nested prior that drops rows makes smaller thansize(X, 1). - Read the prior probabilities
w0on that axis withep_prior_probabilities. They arepe.wwhere the caller set one,pr.wwhere the fit answered one, and the uniform1/Totherwise. A caller'spe.wreaches the wrapped estimator throughfactory, andpris refitted under it. - Build every view against that one
pr: the mean, value at risk, conditional, entropic and relativistic value at risk, variance, covariance, skewness, kurtosis and correlation views. Each row that is linear in the posterior probabilities reaches the constraint dictionaryepc, and each tail view that needs auxiliary variables reaches the tail view vectortvs. No asset's mean or variance is pinned. - Where
epcortvsis non-empty, solve once fromw0withentropy_pooling, givingw1, and refitpratw1. Every row of every family can drop understrict = false, and the view set then states nothing:w1isw0,kldis zero, and no refit runs. - Compute
ens, the effective number of scenarios ofw1, andkld, the divergence ofw1fromw0. - Return a
LowOrderPriorcarrying the refit moments,w1,ensandkld. The feature matrix and the factor block come fromprunchanged.
Arguments
alg: Single-shot entropy pooling algorithm.pe: Entropy pooling prior estimator.X: Asset returns matrix, already oriented.F: Optional factor returns matrix, already oriented.pnl: OptionalAssetPanel, the panel the carrier held. A wrapping prior forwards it unchanged, so that it can compose an estimator that is fitted on a panel. An estimator that reads no panel ignores it.strict: Iftrue, throws error for missing assets; otherwise, issue warnings.kwargs...: Additional keyword arguments forwarded to the wrapped prior estimator.
Returns
pr::LowOrderPrior: Prior result carrying the posterior probability weights.
Related