Skip to content
11

Simple expected returns

The most basic moment is the simple expected return. These types and functions implement it.

PortfolioOptimisers.SimpleExpectedReturns Type
julia
struct SimpleExpectedReturns{T1, T2} <: AbstractExpectedReturnsEstimator
    w::T1
    idx::T2
end

A simple expected returns estimator for PortfolioOptimisers.jl, representing the sample mean with optional observation weights.

SimpleExpectedReturns is the standard estimator for computing expected returns as the (possibly weighted) mean of asset returns. It supports both unweighted and weighted mean estimation by storing an optional weights vector.

Fields

  • w: Optional weights for each observation. If nothing, the unweighted mean is computed.

  • idx: Optional indices of the observations to use for estimation. If nothing, all observations are used.

Constructor

julia
SimpleExpectedReturns(; w::Option{<:StatsBase.AbstractWeights} = nothing,
                       idx::Option{<:VecInt} = nothing)

Keyword arguments correspond to the fields above.

Validation

julia
- If `w` is not `nothing`, `!isempty(w)`.
- If `idx` is not `nothing`, `!isempty(idx)` and all indices are positive integers.

Examples

julia
julia> SimpleExpectedReturns()
SimpleExpectedReturns
    w ┼ nothing
  idx ┴ nothing

julia> SimpleExpectedReturns(; w = StatsBase.Weights([0.5, 0.5]))
SimpleExpectedReturns
    w ┼ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.5, 0.5]
  idx ┴ nothing

Related

source
PortfolioOptimisers.factory Method
julia
factory(me::SimpleExpectedReturns, w::StatsBase.AbstractWeights)

Create a new SimpleExpectedReturns estimator with observation weights w.

This function constructs a new SimpleExpectedReturns object, replacing the weights stored in the input estimator with the provided weights.

Arguments

  • me: Expected returns estimator.

  • w: Observation weights vector.

Returns

  • me::SimpleExpectedReturns: New estimator with observation weights w.

Related

source
Statistics.mean Method
julia
Statistics.mean(me::SimpleExpectedReturns, X::MatNum; dims::Int = 1, kwargs...)

Compute the mean of asset returns using a SimpleExpectedReturns estimator.

This method computes the expected returns as the sample mean of the input data X, optionally using observation weights stored in the estimator. If no weights are provided, the unweighted mean is computed.

Arguments

  • me: Expected returns estimator.

  • X: Data matrix.

  • dims: Dimensions along which to perform the computation.

  • kwargs...: Additional keyword arguments passed to Statistics.mean.

Returns

  • mu::VecNum: The expected returns vector.

Examples

julia
julia> X = [0.01 0.02; 0.03 0.04];

julia> ser = SimpleExpectedReturns()
SimpleExpectedReturns
    w ┼ nothing
  idx ┴ nothing

julia> mean(ser, X)
1×2 Matrix{Float64}:
 0.02  0.03

julia> serw = SimpleExpectedReturns(; w = StatsBase.Weights([0.2, 0.8]))
SimpleExpectedReturns
    w ┼ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.2, 0.8]
  idx ┴ nothing

julia> mean(serw, X)
1×2 Matrix{Float64}:
 0.026  0.036

Related

source