Regime Adjusted Exponential Weighted Covariance
Types
PortfolioOptimisers.RegimeAdjustedTarget Type
abstract type RegimeAdjustedTarget <: AbstractAlgorithmAbstract 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 to1.
Arguments
target: The concrete target instance.
Returns
n::Int: Minimum required active assets.
Examples
julia> struct MyTarget <: PortfolioOptimisers.RegimeAdjustedTarget end
julia> PortfolioOptimisers.min_active_assets(MyTarget())
1Related
sourcePortfolioOptimisers.MahalanobisTarget Type
struct MahalanobisTarget <: RegimeAdjustedTargetRegime-adjustment target that uses a Mahalanobis-distance-based baseline covariance structure. Requires at least two active assets.
Related
sourcePortfolioOptimisers.DiagonalTarget Type
struct DiagonalTarget <: RegimeAdjustedTargetRegime-adjustment target that uses a diagonal baseline covariance structure.
Related
sourcePortfolioOptimisers.PortfolioTarget Type
struct PortfolioTarget{__T_w} <: RegimeAdjustedTargetRegime-adjustment target that uses a portfolio-weighted baseline covariance structure.
Fields
w: Optional portfolio weights vector for the portfolio target. Ifnothing, equal weights are used.
Constructors
PortfolioTarget(;
w::Option{<:EstValType} = nothing
) -> PortfolioTargetKeywords correspond to the struct's fields.
Validation
- If
wis anAbstractVector,!isempty(w).
Examples
julia> PortfolioTarget()
PortfolioTarget
w ┴ nothingRelated
sourcePortfolioOptimisers.RegimeAdjustedExpWeightedCovariance Type
struct RegimeAdjustedExpWeightedCovariance{__T_decay, __T_cor_decay, __T_hac_lags, __T_regime_method, __T_regime_decay, __T_regime_target} <: AbstractCovarianceEstimatorOnline 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
Where:
: EWM covariance between assets and at time . : Covariance decay factor. : Return of asset at time . : Mean return of asset .
Where:
: EWM correlation between assets and at time . : Correlation decay factor. : EWM variance of asset at time .
The regime state regime_decay. Final covariance:
Where:
: Regime-adjusted covariance between assets and . : Regime multiplier derived from the smoothed regime state . : Final EWM correlation. : Final EWM variance of asset .
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. Ifnothing, 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
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()
) -> RegimeAdjustedExpWeightedCovarianceKeywords correspond to the struct's fields.
Validation
decay > 0.If
hac_lagsis notnothing,hac_lags > 0.
Examples
julia> ce = RegimeAdjustedExpWeightedCovariance();
julia> ce.decay ≈ exp2(-inv(40.0))
trueRelated
PortfolioOptimisers.min_active_assets Function
min_active_assets(_::RegimeAdjustedTarget) -> Int64Returns 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
sourcemin_active_assets(_::MahalanobisTarget) -> Int64Returns 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