Empirical Prior: private API
PortfolioOptimisers.show_fields — Method
show_fields(
pe::EmpiricalPrior
) -> Union{NTuple{4, Symbol}, NTuple{5, Symbol}}
Renders every field of an EmpiricalPrior except cache, and max_scenarios only where it is set.
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. max_scenarios is a cap most callers never set, and a nothing row for it would move every rendering of every host that carries a prior; it appears exactly where a caller chose one. Set set_show_nothing_fields!(:EmpiricalPrior, true) to render both.
Arguments
pe: Empirical prior estimator.
Returns
fields::Tuple: The field names to render, which is(:ce, :me, :horizon, :fill_limit)with no scenario cap and(:ce, :me, :horizon, :fill_limit, :max_scenarios)with one.
Related
PortfolioOptimisers.horizon_moments! — Function
horizon_moments!(
mu::AbstractVector{<:Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}},
sigma::AbstractMatrix{<:Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}},
horizon::Number
)
Scales a pair of log-return moments to an investment horizon and converts them to arithmetic returns, in place.
The horizon algebra of EmpiricalPrior, written once. The batch method reaches it after fitting pe.me and pe.ce on log1p.(X), and the read-out of a folded prior reaches it after reading the same two moments off their states, so the two answer identically by construction rather than by a test over two copies of the arithmetic.
Mathematical definition
\[\begin{align} \tilde{\boldsymbol{\mu}} &= h \cdot \hat{\boldsymbol{\mu}}_{\log}\,, & \tilde{\mathbf{\Sigma}} &= h \cdot \hat{\mathbf{\Sigma}}_{\log}\,, \\ \hat{\mu}_i &= \exp\!\left(\tilde{\mu}_i + \tfrac{1}{2}\tilde{\sigma}_{ii}\right) - 1\,, & \hat{\sigma}_{ij} &= (\hat{\mu}_i + 1)(\hat{\mu}_j + 1)\left(\exp(\tilde{\sigma}_{ij}) - 1\right)\,. \end{align}\]
Where:
- $h$: Investment horizon.
- $\hat{\boldsymbol{\mu}}_{\log}$, $\hat{\mathbf{\Sigma}}_{\log}$: Mean and covariance of the log-returns.
- $\hat{\mu}_i$, $\hat{\sigma}_{ij}$: Arithmetic mean return and covariance.
Algorithm
The order of steps 3 and 4 is not free. Step 4 reads the mu step 3 left, which is $\hat{\mu}_i + 1$ and not $\hat{\mu}_i$, because step 5 has not yet subtracted the one, and the second closed form asks for exactly that factor. Moving step 5 in front of step 4 replaces each $\hat{\mu}_i + 1$ by $\hat{\mu}_i$, and on a daily return series that collapses the covariance to a small fraction of its value.
- Scale
mubyhorizon. - Scale
sigmabyhorizon. - Overwrite
muwith the exponential of the first closed form, which is the arithmetic mean plus one. - Overwrite
sigmawith the second closed form, whose $\hat{\mu}_i + 1$ factors are themuof step 3. - Subtract one from
mu.
Arguments
mu: The log-return mean, overwritten with the arithmetic mean.sigma: The log-return covariance, overwritten with the arithmetic covariance.horizon: The investment horizon.
Returns
nothing. Both arguments are modified in place.
Related