Skip to content
13

Regime Adjusted Exponential Weighted Covariance

Types

PortfolioOptimisers.RegimeAdjustedTarget Type
julia
abstract type RegimeAdjustedTarget <: AbstractAlgorithm

Abstract supertype for all regime-adjustment target structures used in RegimeAdjustedExpWeightedCovariance.

A target defines how the regime-adjusted covariance update is structured (e.g., which baseline covariance form is shrunk toward).

Interfaces

In order to implement a new regime-adjustment target, subtype RegimeAdjustedTarget and optionally implement min_active_assets.

min_active_assets interface

  • min_active_assets(target::RegimeAdjustedTarget) -> Int: Returns the minimum number of active assets required to use this target. Defaults to 1.

Arguments

  • target: The concrete target instance.

Returns

  • n::Int: Minimum required active assets.

Examples

julia
julia> struct MyTarget <: PortfolioOptimisers.RegimeAdjustedTarget end

julia> PortfolioOptimisers.min_active_assets(MyTarget())
1

Related

source
PortfolioOptimisers.MahalanobisTarget Type
julia
struct MahalanobisTarget <: RegimeAdjustedTarget

Regime-adjustment target that uses a Mahalanobis-distance-based baseline covariance structure. Requires at least two active assets.

Related

source
PortfolioOptimisers.DiagonalTarget Type
julia
struct DiagonalTarget <: RegimeAdjustedTarget

Regime-adjustment target that uses a diagonal baseline covariance structure.

Related

source
PortfolioOptimisers.PortfolioTarget Type
julia
struct PortfolioTarget{__T_w} <: RegimeAdjustedTarget

Regime-adjustment target that uses a portfolio-weighted baseline covariance structure.

Fields

  • w: Optional portfolio weights vector for the portfolio target. If nothing, equal weights are used.

Constructors

julia
PortfolioTarget(;
    w::Option{<:EstValType} = nothing
) -> PortfolioTarget

Keywords correspond to the struct's fields.

Validation

  • If w is an AbstractVector, !isempty(w).

Examples

julia
julia> PortfolioTarget()
PortfolioTarget
  w ┴ nothing

Related

source
PortfolioOptimisers.RegimeAdjustedExpWeightedCovariance Type
julia
struct RegimeAdjustedExpWeightedCovariance{__T_decay, __T_cor_decay, __T_hac_lags, __T_regime_method, __T_regime_decay, __T_regime_target} <: AbstractCovarianceEstimator

Online exponentially weighted covariance estimator with regime-state adjustment.

Maintains separate exponentially weighted running means for the covariance and the correlation, combining them at each step. After processing all observations, the result is scaled by the squared regime multiplier derived from the smoothed regime state.

Mathematical definition

EWM covariance update (decay λ) and correlation (decay λc):

Cij,t=λCij,t1+(1λ)(ri,tr¯i)(rj,tr¯j).

Where:

  • Cij,t: EWM covariance between assets i and j at time t.

  • λ: Covariance decay factor.

  • ri,t: Return of asset i at time t.

  • r¯i: Mean return of asset i.

ρij,t=λcρij,t1+(1λc)(ri,tr¯i)(rj,tr¯j)vi,tvj,t.

Where:

  • ρij,t: EWM correlation between assets i and j at time t.

  • λc: Correlation decay factor.

  • vi,t: EWM variance of asset i at time t.

The regime state st is smoothed from zt2 using regime_decay. Final covariance:

Σ^ij=mult(sT)2ρij,Tvi,Tvj,T.

Where:

  • Σ^ij: Regime-adjusted covariance between assets i and j.

  • mult(sT): Regime multiplier derived from the smoothed regime state sT.

  • ρij,T: Final EWM correlation.

  • vi,T: Final EWM variance of asset i.

Fields

  • decay: Exponential decay factor for the exponentially weighted estimator.

  • cor_decay: Exponential decay factor for the correlation smoother.

  • hac_lags: Optional number of lags for Heteroskedasticity and Autocorrelation Consistent (HAC) kernel correction of squared returns. If nothing, no HAC correction is applied.

  • regime_method: Regime adjustment method used to compute the per-observation regime state.

  • regime_decay: Exponential decay factor for smoothing the regime state.

  • regime_target: Target structure for the regime-adjusted covariance update.

Constructors

julia
RegimeAdjustedExpWeightedCovariance(;
    decay::Number                        = exp2(-inv(40.0)),
    cor_decay::Number                    = exp2(-inv(20.0)),
    hac_lags::Option{<:Integer}          = nothing,
    regime_method::RegimeAdjustedMethod  = FirstMomentRegimeAdjusted(),
    regime_decay::Number                 = exp2(-2 / inv(log2(inv(decay)))),
    regime_target::RegimeAdjustedTarget  = DiagonalTarget()
) -> RegimeAdjustedExpWeightedCovariance

Keywords correspond to the struct's fields.

Validation

  • decay > 0.

  • If hac_lags is not nothing, hac_lags > 0.

Examples

julia
julia> ce = RegimeAdjustedExpWeightedCovariance();

julia> ce.decay  exp2(-inv(40.0))
true

Related

source
PortfolioOptimisers.min_active_assets Function
julia
min_active_assets(_::RegimeAdjustedTarget) -> Int64

Returns the minimum number of active assets required for this regime-adjustment target.

Arguments

  • ::RegimeAdjustedTarget: Regime-adjustment target (unused by this default method).

Returns

  • 1::Int: The default minimum is one active asset.

Related

source
julia
min_active_assets(_::MahalanobisTarget) -> Int64

Returns the minimum number of active assets required for the Mahalanobis target.

Arguments

  • ::MahalanobisTarget: Mahalanobis regime-adjustment target (unused).

Returns

  • 2::Int: At least two active assets are required.

Related

source