Skip to content
13

Windowed expected returns

PortfolioOptimisers.WindowedExpectedReturns Type
julia
struct WindowedExpectedReturns{__T_me, __T_w, __T_window} <: AbstractExpectedReturnsEstimator

Expected returns estimator that restricts computation to a rolling or indexed observation window.

WindowedExpectedReturns wraps another expected returns estimator and applies it to a subset of observations defined by a window and/or custom observation weights. This enables time-varying or recency-weighted expected returns estimation.

Fields

  • me: Expected returns estimator.

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

  • window: Window specification: an integer (last window observations) or a vector of indices.

Constructors

julia
WindowedExpectedReturns(;
    me::AbstractExpectedReturnsEstimator = SimpleExpectedReturns(),
    w::Option{<:ObsWeights} = nothing,
    window::Option{<:Int_VecInt} = nothing
) -> WindowedExpectedReturns

Keywords correspond to the struct's fields.

Validation

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

  • If window is provided, it must be nonempty, nonnegative, and finite.

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

View parameters

When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:

Examples

julia
julia> WindowedExpectedReturns()
WindowedExpectedReturns
      me ┼ SimpleExpectedReturns
         │   w ┴ nothing
       w ┼ nothing
  window ┴ nothing

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.

Examples

julia
julia> factory(nothing, 1, 2; x = 3)

julia> factory(MeanValue())
MeanValue
  w ┴ nothing

Related

source
Statistics.mean Method
julia
Statistics.mean(me::WindowedExpectedReturns, X::MatNum; dims::Int = 1, iv::Option{<:MatNum} = nothing, kwargs...)

Compute expected returns using a rolling or indexed observation window.

This method selects a window of observations from X (and applies observation weights if specified), then delegates to the underlying mean estimator.

Arguments

  • me: Windowed expected returns estimator.

  • X: Data matrix of asset returns (observations × assets).

  • dims: Dimension along which to perform the computation.

  • iv: Optional implied volatility matrix. Used if any internal covariance estimator is an instance of ImpliedVolatility.

  • kwargs...: Additional keyword arguments passed to the underlying estimator.

Returns

  • mu::ArrNum: Expected returns vector for the selected window.

Related

source