Standard deviation expected returns
PortfolioOptimisers.StandardDeviationExpectedReturns — Type
struct StandardDeviationExpectedReturns{__T_ce} <: AbstractExpectedReturnsEstimatorExpected returns estimator that returns the asset standard deviations.
StandardDeviationExpectedReturns computes "expected returns" as the standard deviation of each asset, as estimated by the underlying covariance estimator. This can be useful in certain risk-based portfolio construction approaches where the expected return proxy is the asset's volatility.
Fields
ce: Covariance estimator.
Constructors
StandardDeviationExpectedReturns(; ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance()) -> StandardDeviationExpectedReturnsKeywords correspond to the struct's fields.
Propagated parameters
When factory is called on this type, the following @fprop-tagged fields are automatically propagated:
ce: Recursively updated viafactory.
View parameters
When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:
ce: Recursively viewed viaport_opt_view.
Examples
julia> StandardDeviationExpectedReturns()StandardDeviationExpectedReturns ce ┼ PortfolioOptimisersCovariance │ ce ┼ Covariance │ │ me ┼ SimpleExpectedReturns │ │ │ w ┴ nothing │ │ ce ┼ GeneralCovariance │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true) │ │ │ w ┴ nothing │ │ alg ┴ FullMoment() │ mp ┼ MatrixProcessing │ │ pdm ┼ Posdef │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ │ dn ┼ nothing │ │ dt ┼ nothing │ │ alg ┼ nothing │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)Related
Statistics.mean — Method
Statistics.mean(me::StandardDeviationExpectedReturns, X::MatNum;
dims::Int = 1, kwargs...)Compute expected returns as the standard deviation of each asset.
This method returns the standard deviation vector of X as estimated by the covariance estimator me.ce.
Mathematical definition
\[\begin{align} \hat{\mu}_j &= \hat{\sigma}_j = \sqrt{\hat{\mathbf{\Sigma}}_{jj}}\,. \end{align}\]
Where:
- $\hat{\mu}_j$: Expected return proxy of asset $j$.
- $\hat{\sigma}_j$: Standard deviation of asset $j$.
- $\hat{\mathbf{\Sigma}}$: Covariance matrix that
me.ceestimates. - $\hat{\mathbf{\Sigma}}_{jj}$: $j$-th diagonal element of $\hat{\mathbf{\Sigma}}$.
Arguments
me: Standard deviation expected returns estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the covariance estimator.
Validation
dims in (1, 2).
Returns
mu::Matrix{<:Number}: Standard deviation vector, shaped as(1, N)ifdims == 1or(N, 1)ifdims == 2.
Details
- The method reads the diagonal of the matrix that
me.cereturns, not a formula of its own. Every choice insideme.cetherefore reaches the result: the moment algorithm, the observation weights, and the matrix processing.
Related
PortfolioOptimisers.VarianceExpectedReturns — Type
struct VarianceExpectedReturns{__T_ce} <: AbstractExpectedReturnsEstimatorExpected returns estimator that returns the asset variances.
VarianceExpectedReturns computes "expected returns" as the variance of each asset, as estimated by the underlying covariance estimator. This can be useful in certain risk-based portfolio construction approaches where the expected return proxy is the asset's variance. Variance is the square of volatility (standard deviation).
Fields
ce: Covariance estimator.
Constructors
VarianceExpectedReturns(; ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance()) -> VarianceExpectedReturnsKeywords correspond to the struct's fields.
Propagated parameters
When factory is called on this type, the following @fprop-tagged fields are automatically propagated:
ce: Recursively updated viafactory.
View parameters
When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:
ce: Recursively viewed viaport_opt_view.
Examples
julia> VarianceExpectedReturns()VarianceExpectedReturns ce ┼ PortfolioOptimisersCovariance │ ce ┼ Covariance │ │ me ┼ SimpleExpectedReturns │ │ │ w ┴ nothing │ │ ce ┼ GeneralCovariance │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true) │ │ │ w ┴ nothing │ │ alg ┴ FullMoment() │ mp ┼ MatrixProcessing │ │ pdm ┼ Posdef │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ │ dn ┼ nothing │ │ dt ┼ nothing │ │ alg ┼ nothing │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg)Related
PortfolioOptimisers.factory — Method
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
<:AbstractResult}, args...; kwargs...) -> a
factory(a::AbstractVector{<:Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
<:AbstractResult}}, args...; kwargs...) -> VectorNo-op factory function for constructing objects with a uniform interface.
Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.
factory and port_opt_view are the two propagation mechanisms in this library. They are duals: factory threads runtime values (prior moments, observation weights, previous portfolio weights) down through a composed struct tree; port_opt_view threads an index selection (a subset of assets or observations) down through the same tree.
The vector method is the one forwarding contract for every vector-valued propagation field: it applies factory to each element and forwards args... and kwargs... unchanged, so a family that admits a vector of estimators, algorithms, or results needs no method of its own. A family that needs more than the forward, such as a concrete element type (concrete_typed_array_if_abstract), defines its own more specific method.
Algorithm
The scalar method:
- Return
aunchanged, and dropargs...andkwargs.... This method is the leaf of the recursion, and it is what makes an untagged type safe to call the verb on.
The vector method:
- For each element
aiofa, callfactoryonai, and forwardargs...andkwargs...unchanged. - Collect the results into a new vector, in the order of
a, and return it.
A @propagatable struct with at least one @fprop- or @wprop-tagged field carries a generated method that dominates the scalar method. That method rebuilds the struct with its keyword constructor, sending each @fprop field through factory_child and each @wprop field through _wprop.
Arguments
a: Indicates no object should be constructed, or a vector whose elements are rebuilt one by one.args...: Arbitrary positional arguments (ignored by the scalar method, forwarded by the vector method).kwargs...: Arbitrary keyword arguments (ignored by the scalar method, forwarded by the vector method).
Returns
a: The input unchanged.v::Vector: The element-wise rebuilds, for the vector method.
Examples
julia> factory(nothing, 1, 2; x = 3)julia> factory(MeanValue())MeanValue w ┴ nothingRelated
Statistics.mean — Method
Statistics.mean(me::VarianceExpectedReturns, X::MatNum;
dims::Int = 1, kwargs...)Compute expected returns as the variance of each asset.
This method returns the variance vector of X as estimated by the covariance estimator me.ce.
Mathematical definition
\[\begin{align} \hat{\mu}_j &= \hat{\sigma}_j^2 = \hat{\mathbf{\Sigma}}_{jj}\,. \end{align}\]
Where:
- $\hat{\mu}_j$: Expected return proxy of asset $j$.
- $\hat{\sigma}_j^2$: Variance of asset $j$.
- $\hat{\mathbf{\Sigma}}$: Covariance matrix that
me.ceestimates. - $\hat{\mathbf{\Sigma}}_{jj}$: $j$-th diagonal element of $\hat{\mathbf{\Sigma}}$.
Arguments
me: Variance expected returns estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.kwargs...: Additional keyword arguments passed to the covariance estimator.
Validation
dims in (1, 2).
Returns
mu::Matrix{<:Number}: Variance vector, shaped as(1, N)ifdims == 1or(N, 1)ifdims == 2.
Details
- The method reads the diagonal of the matrix that
me.cereturns, not a formula of its own. Every choice insideme.cetherefore reaches the result: the moment algorithm, the observation weights, and the matrix processing.
Related