Windowed preamble

A windowed estimator under SeedWindow folds. These methods fold it and read its estimate out of the fold. The private page documents the other names of this topic.

PortfolioOptimisers.supports_partial_fit — Method
supports_partial_fit(
    _::Union{WindowedCokurtosis{<:Any, <:Any, <:Any, <:SeedWindow}, WindowedCoskewness{<:Any, <:Any, <:Any, <:SeedWindow}, WindowedCovariance{<:Any, <:Any, <:Any, <:SeedWindow}, WindowedExpectedReturns{<:Any, <:Any, <:Any, <:SeedWindow}, WindowedVariance{<:Any, <:Any, <:Any, <:SeedWindow}}
) -> Bool

Answers that a windowed estimator under a SeedWindow folds.

A prior that carries the observations, such as the carry of EmpiricalPrior, folds each member that folds, and refits the others over its rows. A seed window must fold, because a refit keeps the rolling window. So the answer is true whatever the inner estimator, and the fold refuses an inner estimator that does not fold with an error that names it, not a silent refit.

Arguments

  • est: Windowed estimator under a seed window.

Returns

  • true.

Related

source
PortfolioOptimisers.partial_fit! — Method
partial_fit!(est::SeedWindowed, X::MatNum; dims::Int = 1, kwargs...)
partial_fit!(est::SeedWindowed, x::VecNum; kwargs...)

Fold a block of observations into a windowed estimator under a SeedWindow.

The first fold cuts the block to the window, as a batch fit does, and folds the rows that remain into the inner estimator. It returns the estimator with window = nothing, so the window is spent, and each later fold passes every row to the inner estimator. The estimator holds no state of its own: its inner estimator holds the state of the fold, and the spent window records that the first fold happened.

The vector method folds one observation as a matrix of one row. So a first fold of one observation keeps it when the window keeps the last row.

Algorithm

  1. Read the inner estimator, the first field that the declaration of the type sets, giving inner.
  2. Resolve the window against the block with get_window, giving win. After the first fold the window is nothing, and win is a Colon.
  3. Cut the block with windowed_rows, and cut the active_mask and estimation_mask keywords with windowed_keywords.
  4. Fold the cut block into inner with partial_fit!.
  5. Return the estimator with the folded inner and window = nothing.

Arguments

  • est: Windowed estimator under a seed window.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • x::VecNum: One observation, with one entry per asset.
  • dims: Dimension along which to perform the computation.
  • kwargs...: Keywords passed to the fold of the inner estimator. The two universe masks are cut to the window.

Validation

  • est.w is nothing, because a weight vector reweights every past observation when a new one arrives. An ArgumentError is thrown otherwise.
  • The inner estimator folds, by supports_partial_fit. An ArgumentError is thrown otherwise.
  • dims in (1, 2).

Returns

  • est: The windowed estimator, with its inner estimator folded and its window spent.

Related

source
Statistics.mean — Method
mean(
    me::WindowedExpectedReturns{<:Any, <:Any, <:Any, <:SeedWindow};
    kwargs...
) -> Any

Read the expected returns out of the fold of a windowed estimator under a SeedWindow.

The inner estimator holds the state of the fold, so the method reads it there.

Arguments

  • me: Windowed expected returns estimator under a seed window.
  • kwargs...: Keywords passed to the read of the inner estimator.

Returns

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

Related

source
Statistics.cov — Method
cov(
    ce::WindowedCovariance{<:Any, <:Any, <:Any, <:SeedWindow};
    kwargs...
) -> Any

Read the covariance out of the fold of a windowed estimator under a SeedWindow.

The inner estimator holds the state of the fold, so the method reads it there.

Arguments

  • ce: Windowed covariance estimator under a seed window.
  • kwargs...: Keywords passed to the read of the inner estimator.

Returns

  • sigma::MatNum: Covariance matrix assets x assets.

Related

source
Statistics.var — Method
var(
    ve::WindowedVariance{<:Any, <:Any, <:Any, <:SeedWindow};
    kwargs...
) -> Any

Read the variance out of the fold of a windowed estimator under a SeedWindow.

The inner estimator holds the state of the fold, so the method reads it there.

Arguments

  • ve: Windowed variance estimator under a seed window.
  • kwargs...: Keywords passed to the read of the inner estimator.

Returns

  • vr::ArrNum: Variance vector of X, reshaped to be consistent with the dimension along which the value is computed.

Related

source
PortfolioOptimisers.coskewness — Method
coskewness(
    ske::WindowedCoskewness{<:Any, <:Any, <:Any, <:SeedWindow};
    kwargs...
) -> Any

Read the coskewness out of the fold of a windowed estimator under a SeedWindow.

The inner estimator holds the state of the fold, so the method reads it there.

Arguments

  • ske: Windowed coskewness estimator under a seed window.
  • kwargs...: Keywords passed to the read of the inner estimator.

Returns

  • cskew::MatNum: Coskewness tensor assets x assets².
  • V::MatNum: Processed coskewness matrix assets x assets.

Related

source
PortfolioOptimisers.cokurtosis — Method
cokurtosis(
    kte::WindowedCokurtosis{<:Any, <:Any, <:Any, <:SeedWindow};
    kwargs...
) -> Any

Read the cokurtosis out of the fold of a windowed estimator under a SeedWindow.

The inner estimator holds the state of the fold, so the method reads it there.

Arguments

  • kte: Windowed cokurtosis estimator under a seed window.
  • kwargs...: Keywords passed to the read of the inner estimator.

Returns

  • kte::MatNum: Cokurtosis matrix assets x assets.

Related

source