Skip to content
13

Simple expected returns

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

PortfolioOptimisers.SimpleExpectedReturns Type
julia
struct SimpleExpectedReturns{__T_w} <: AbstractExpectedReturnsEstimator

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.

Fields

  • w: Optional observation weights vector observations × 1, or a concrete subtype of DynamicAbstractWeights. If nothing, the computation is unweighted.

Constructors

julia
SimpleExpectedReturns(;
    w::Option{<:ObsWeights} = nothing
) -> SimpleExpectedReturns

Keywords correspond to the struct's fields.

Validation

  • If w is not nothing, !isempty(w).

Examples

julia
julia> SimpleExpectedReturns()
SimpleExpectedReturns
  w ┴ nothing

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

Related

source
PortfolioOptimisers.factory Method
julia
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                 <:AbstractResult}, args...; kwargs...) -> a

No-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.

Arguments

  • a: Indicates no object should be constructed.

  • args...: Arbitrary positional arguments (ignored).

  • kwargs...: Arbitrary keyword arguments (ignored).

Returns

  • a: The input unchanged.

Related

source
julia
factory(
    me::SimpleExpectedReturns,
    w::ObsWeights
) -> SimpleExpectedReturns

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 observations × 1.

Returns

  • me: New expected returns estimator of the same type as the argument, with the appropriate weights applied.

Examples

julia
julia> me = SimpleExpectedReturns()
SimpleExpectedReturns
  w ┴ nothing

julia> factory(me, StatsBase.Weights([0.1, 0.2, 0.7]))
SimpleExpectedReturns
  w ┴ StatsBase.Weights{Float64, Float64, Vector{Float64}}: [0.1, 0.2, 0.7]

Related

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

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 according to ce.

Arguments

  • me: Expected returns estimator.

  • X: Data matrix observations × features if the dims keyword does not exist or dims = 1, features × observations when dims = 2.

  • dims: Dimension along which to perform the computation.

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

Returns

  • mu::ArrNum: Expected returns vector features x 1 if the dims keyword does not exist or dims = 2, 1 x features if dims = 1.

Examples

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

julia> ser = SimpleExpectedReturns()
SimpleExpectedReturns
  w ┴ 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]

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

Related

source