Windowed Coskewness
PortfolioOptimisers.WindowedCoskewness — Type
struct WindowedCoskewness{__T_ske, __T_w, __T_window} <: CoskewnessEstimatorCoskewness estimator that restricts computation to a rolling or indexed observation window.
WindowedCoskewness wraps another coskewness 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 coskewness estimation.
Fields
ske: Coskewness estimator.w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.window: Observation window. An integer selects the lastwindowobservations, and a vector of indices selects those observations.
Constructors
WindowedCoskewness(; ske::CoskewnessEstimator = Coskewness(), w::Option{<:ObsWeights} = nothing, window::Option{<:Int_VecInt} = nothing) -> WindowedCoskewnessKeywords correspond to the struct's fields.
Validation
- If
wis notnothing,!isempty(w). - If
windowis 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:
ske: Recursively updated viafactory.w: Replaced with the incomingObsWeights.
View parameters
When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:
ske: Recursively viewed viaport_opt_view.
Observation weight parameters
When obs_weights_view is called on this type, the following fields are automatically indexed to the selected observations:
ske: Recursively indexed viaobs_weights_view.w: Indexed to the selected observations viaobs_weights_view.
Examples
julia> WindowedCoskewness()WindowedCoskewness ske ┼ Coskewness │ me ┼ SimpleExpectedReturns │ │ w ┴ nothing │ mp ┼ MatrixProcessing │ │ pdm ┼ Posdef │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ │ dn ┼ nothing │ │ dt ┼ nothing │ │ alg ┼ nothing │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg) │ alg ┼ FullMoment() │ w ┼ nothing │ cache ┴ nothing w ┼ nothing window ┴ nothingRelated
PortfolioOptimisers.coskewness — Method
coskewness(ske::WindowedCoskewness, X::MatNum; dims::Int = 1, mean = nothing, iv::Option{<:MatNum} = nothing, kwargs...)Compute coskewness over a rolling or indexed observation window (matrix input).
This method selects a window of observations from X (and applies observation weights if specified), then delegates to the underlying coskewness estimator.
Algorithm
- Resolve the window and the observation weights with
windowed_preamble, givinginner, a copy ofske.skethat carries the windowed weights, together with the windowedXand the windowediv. - Call
coskewnessoninnerand the windowedX, and return its result. The inner estimator alone decides the value, so the window and the weights are the whole of this method's contribution.
Arguments
ske: Windowed coskewness estimator.X: Data matrix of asset returns (observations × assets).dims: Dimension along which to perform the computation.mean: Optional pre-computed mean passed to the underlying estimator.iv: Optional implied volatility matrix. Used if any internal covariance estimator is an instance ofImpliedVolatility.kwargs...: Additional keyword arguments passed to the underlying estimator.
Returns
cskew::MatNum: Coskewness tensorassets x assets².V::MatNum: Processed coskewness matrixassets x assets.
Related