Windowed variance: private API

Functions

PortfolioOptimisers.variance_series — Method
variance_series(
    ve::WindowedVariance,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}};
    dims,
    kwargs...
) -> Matrix

Compute the point-in-time variance series of a windowed variance estimator.

Row t is the fit of the estimator on the observations 1 to t. The estimator keeps the last observations of its window among them, so the window rolls with t, and the last row equals the batch fit. Before the window is full, row t keeps every observation from 1 to t. variance_series(est, w::Option{<:ObsWeights}, window::Option{<:Int_VecInt}, X::MatNum, pnl::Option{<:AssetPanel}) states the rule.

A prior calls this method in its variance slot, with the active_mask and estimation_mask keywords, and each fit cuts them to its own rows.

Arguments

  • ve: Windowed variance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which the computation runs.
  • kwargs...: Keywords passed to the inner estimator. The two universe masks are cut to the rows of each fit.

Validation

  • dims in (1, 2).
  • When the window keeps no observation of the first row, the element type of the variance holds NaN. An Integer or a Rational element type raises an ArgumentError.

Returns

  • val::Matrix{<:Number}: Variance series, shaped as (T, N) if dims == 1 or (N, T) if dims == 2.

Related

source
PortfolioOptimisers.variance_series — Method
variance_series(
    ve::WindowedVariance,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    kwargs...
) -> Matrix

Compute the point-in-time variance series of a windowed variance estimator from an Asset Panel.

Row t is the fit of the estimator on the observations 1 to t of the returns and of the panel, as in variance_series(ve::WindowedVariance, X::MatNum; dims::Int = 1, kwargs...). Each fit gives the inner estimator the panel over its own rows, so a mask-aware inner estimator reads the active mask of the window, and a plain one reduces to the Coverage Universe of the window.

Arguments

  • ve: Windowed variance estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • pnl: Optional AssetPanel. The Coverage Universe of the fit comes from its active mask. If it is nothing, the rule reads only the finiteness of the returns.
  • dims: Dimension along which the computation runs.
  • kwargs...: Keywords passed to the inner estimator.

Validation

  • dims in (1, 2).
  • When the window keeps no observation of the first row, the element type of the variance holds NaN. An Integer or a Rational element type raises an ArgumentError.
  • When an asset is outside the Coverage Universe, the element type of the moment holds NaN. An Integer or a Rational element type raises an ArgumentError.

Returns

  • val::Matrix{<:Number}: Variance series, shaped as (T, N) if dims == 1 or (N, T) if dims == 2.

Related

source