Schur Complement Hierarchical Risk Parity
PortfolioOptimisers.SchurComplementAlgorithm Type
abstract type SchurComplementAlgorithm <: AbstractAlgorithmAbstract supertype for Schur Complement algorithm variants.
Related
sourcePortfolioOptimisers.NonMonotonicSchurComplement Type
struct NonMonotonicSchurComplement <: SchurComplementAlgorithmNon-monotonic Schur Complement algorithm variant for SCHRP.
Uses the raw Schur complement formula without monotonicity correction.
Related
sourcePortfolioOptimisers.MonotonicSchurComplement Type
struct MonotonicSchurComplement{__T_N, __T_tol, __T_iter, __T_strict} <: SchurComplementAlgorithmMonotonic Schur Complement algorithm variant for SCHRP.
Applies a bisection-based correction to ensure the Schur complement allocation factor tol and maximum iterations iter.
Fields
N: Number of bisection steps for the monotonic Schur complement.tol: Convergence tolerance.iter: Maximum number of iterations.strict: Whether to raise an error if convergence is not achieved.
Constructors
MonotonicSchurComplement(;
N::Integer = 10,
tol::Number = 1e-4,
iter::Option{<:Integer} = nothing,
strict::Bool = false
) -> MonotonicSchurComplementKeywords correspond to the struct's fields.
Related
sourcePortfolioOptimisers.SchurComplementParams Type
struct SchurComplementParams{__T_r, __T_gamma, __T_pdm, __T_alg, __T_flag} <: AbstractAlgorithmParameters for the Schur Complement step of SCHRP.
SchurComplementParams collects the risk measure, initial allocation factor
Fields
r: Risk measure or vector of risk measures.gamma: Schur complement decomposition parameter.pdm: Positive definite matrix estimator.alg: Schur complement algorithm variant.flag: Algorithm selection flag.
Constructors
SchurComplementParams(;
r::Sd_Var = Variance(),
gamma::Number = 0.5,
pdm::Option{<:Posdef} = Posdef(),
alg::SchurComplementAlgorithm = MonotonicSchurComplement(),
flag::Bool = true
) -> SchurComplementParamsKeywords correspond to the struct's fields.
Validation
0 <= gamma <= 1.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(sp, i, X)Get a view or subset of Schur complement parameters for cluster index i.
Returns a SchurComplementParams with the risk measure sliced for the given cluster index. Used internally when iterating over cluster levels.
Arguments
sp:SchurComplementParamsor vector thereof.i: Cluster index or range.X: Data matrix (used for slicing risk measures).
Returns
- Sliced
SchurComplementParams.
Related
sourcePortfolioOptimisers.Sd_Var Type
const Sd_Var = Union{<:StandardDeviation, <:Variance}Alias for a standard deviation or variance risk measure.
Used in the Schur Complement HRP to accept either risk measure type for computing naive portfolio risk.
Related
sourcePortfolioOptimisers.naive_portfolio_risk Method
naive_portfolio_risk(r, sigma)Compute the naive (inverse-volatility) portfolio risk for a given risk measure.
Returns the portfolio risk when weights are set to the inverse-variance or inverse-volatility allocation (i.e., w = 1/diag(sigma), normalised to sum to one). Dispatches on the risk measure type.
Arguments
r: Risk measure (VarianceorStandardDeviation).sigma: Covariance matrix.
Returns
- Scalar portfolio risk.
Related
sourcePortfolioOptimisers.symmetric_step_up_matrix Method
symmetric_step_up_matrix(n1::Integer, n2::Integer)Construct a symmetric step-up matrix for Schur complement augmentation.
Builds a matrix that maps between cluster levels of sizes n1 and n2. Requires |n1 - n2| <= 1.
Arguments
n1: Number of rows (one cluster level size).n2: Number of columns (adjacent cluster level size).
Returns
- A numeric matrix of size
n1 × n2.
Related
sourcePortfolioOptimisers.schur_augmentation Method
schur_augmentation(A, B, C, gamma)Apply the Schur complement augmentation to a risk sub-matrix.
Computes the augmented matrix A - gamma * B * inv(C) * B' and applies a step-up matrix correction. Used internally in the SCHRP algorithm to decompose inter-cluster risk.
Arguments
A: Intra-cluster covariance sub-matrix.B: Off-diagonal cross-cluster covariance sub-matrix.C: Inter-cluster covariance sub-matrix.gamma: Schur complement scaling parameter.
Returns
- Augmented matrix.
Related
sourcePortfolioOptimisers.schur_complement_binary_search Method
schur_complement_binary_search(objective, lgamma, hgamma, ...)Binary search for the optimal Schur complement scaling parameter γ.
Performs binary search in the interval [lgamma, hgamma] to find the γ value that satisfies the monotonicity condition for the Schur complement HRP.
Arguments
objective: Function to evaluate monotonicity.lgamma: Lower bound for γ search.hgamma: Upper bound for γ search.Additional tolerance and iteration parameters.
Returns
- Optimal γ value.
Related
sourcePortfolioOptimisers.schur_complement_weights Function
schur_complement_weights(pr, items, ...)Compute HRP/HERC weights using the Schur complement method.
Allocates weights across cluster levels using the Schur complement of the covariance matrix, providing more accurate inter-cluster risk decomposition than naive HRP.
Arguments
pr: Prior result containing asset moments.items: Vector of vectors of asset indices per cluster level.Additional parameters from
SchurComplementParams.
Returns
- Portfolio weight vector.
Related
sourcePortfolioOptimisers.schur_complement_weights Method
schur_complement_weights(
pr::AbstractPriorResult,
items::AbstractVector{<:AbstractVector{<:Integer}},
wb::WeightBounds,
params::SchurComplementParams{<:Any, <:Any, <:Any, <:MonotonicSchurComplement}
) -> Tuple{Any, Any}Compute SCHRP weights using the monotonic Schur complement method.
Uses binary search to find the γ value that maximises risk reduction while maintaining monotonicity, then delegates to the non-monotonic overload.
Related
sourcePortfolioOptimisers.VecScP Type
const VecScP = AbstractVector{<:SchurComplementParams}Alias for a vector of Schur complement parameters.
Represents a collection of SchurComplementParams objects, used when different cluster levels have different Schur complement configurations.
Related
sourcePortfolioOptimisers.ScP_VecScP Type
const ScP_VecScP = Union{<:SchurComplementParams, <:VecScP}Alias for a single or vector of Schur complement parameters.
Matches either a single SchurComplementParams or a vector of them (VecScP).
Related
sourcePortfolioOptimisers.SchurComplementHierarchicalRiskParityResult Type
struct SchurComplementHierarchicalRiskParityResult{__T_oe, __T_pr, __T_wb, __T_clr, __T_gamma, __T_retcode, __T_w, __T_fb} <: NonJuMPOptimisationResultResult type returned by SchurComplementHierarchicalRiskParity optimisation.
Stores the optimisation estimator, prior result, weight bounds, clustering result, Schur complement scaling parameter, return code, optimised weights, and optional fallback estimator.
Fields
oe: Type of the optimisation estimator that produced this result.pr: Prior result.wb: Weight bounds.clr: Clusters result.gamma: Schur complement decomposition parameter.retcode: Optimisation return code.w: Portfolio weights vectorassets × 1.fb: Fallback result or estimator.
Related
sourcePortfolioOptimisers.factory Method
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
<:AbstractResult}, args...; kwargs...) -> aNo-op factory function for constructing objects with a uniform interface.
Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.
Arguments
a: Indicates no object should be constructed.args...: Arbitrary positional arguments (ignored).kwargs...: Arbitrary keyword arguments (ignored).
Returns
a: The input unchanged.
Examples
julia> factory(nothing, 1, 2; x = 3)
julia> factory(MeanValue())
MeanValue
w ┴ nothingRelated
sourcefactory(res::NonFiniteAllocationOptimisationResult, fb::Option{<:OptE_Opt})Rebuild a continuous optimisation result with an updated fallback optimiser fb.
Every optimisation result carries fb as its last field, so the generic rebuild copies all fields unchanged except the trailing fb. Concrete result types may override this method when rebuilding requires more than swapping fb.
Related
sourcefactory(
opt::Union{NonFiniteAllocationOptimisationEstimator, NonFiniteAllocationOptimisationResult},
_
) -> RandomWeighted{_A, var"#s179", _B, _C, _D, var"#s1791", _E, Bool} where {_A, var"#s179"<:AbstractRNG, _B, _C, _D, var"#s1791"<:WeightFinaliser, _E}Return opt unchanged.
Default pass-through factory for optimisation estimators and results. Overridden for estimators that carry parameters requiring update at each optimisation step.
Related
sourcePortfolioOptimisers.SchurComplementHierarchicalRiskParity Type
struct SchurComplementHierarchicalRiskParity{__T_opt, __T_params, __T_fb} <: ClusteringOptimisationEstimatorSchur Complement Hierarchical Risk Parity (SCHRP) portfolio optimiser.
SchurComplementHierarchicalRiskParity extends HRP by using the Schur complement of the covariance matrix to more accurately decompose inter-cluster risk when allocating portfolio weights across the dendrogram.
Fields
opt: Base hierarchical optimiser configuration.params: Schur complement decomposition parameters.fb: Fallback result or estimator.
Constructors
SchurComplementHierarchicalRiskParity(;
opt::HierarchicalOptimiser = HierarchicalOptimiser(),
params::ScP_VecScP = SchurComplementParams(),
fb::Option{<:OptE_Opt} = nothing
) -> SchurComplementHierarchicalRiskParityKeywords correspond to the struct's fields.
Validation
- If
paramsis a vector:!isempty(params).
Propagated parameters
When factory is called on this type, the following @fprop-tagged fields are automatically propagated:
Examples
julia> SchurComplementHierarchicalRiskParity()
SchurComplementHierarchicalRiskParity
opt ┼ HierarchicalOptimiser
│ pe ┼ EmpiricalPrior
│ │ ce ┼ PortfolioOptimisersCovariance
│ │ │ ce ┼ Covariance
│ │ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ │ w ┴ nothing
│ │ │ │ ce ┼ GeneralCovariance
│ │ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ │ w ┴ nothing
│ │ │ │ alg ┴ Full()
│ │ │ 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)
│ │ me ┼ SimpleExpectedReturns
│ │ │ w ┴ nothing
│ │ horizon ┴ nothing
│ cle ┼ ClustersEstimator
│ │ ce ┼ PortfolioOptimisersCovariance
│ │ │ ce ┼ Covariance
│ │ │ │ me ┼ SimpleExpectedReturns
│ │ │ │ │ w ┴ nothing
│ │ │ │ ce ┼ GeneralCovariance
│ │ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
│ │ │ │ │ w ┴ nothing
│ │ │ │ alg ┴ Full()
│ │ │ 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)
│ │ de ┼ Distance
│ │ │ power ┼ nothing
│ │ │ alg ┴ CanonicalDistance()
│ │ alg ┼ HClustAlgorithm
│ │ │ linkage ┴ Symbol: :ward
│ │ onc ┼ OptimalNumberClusters
│ │ │ max_k ┼ nothing
│ │ │ alg ┼ SecondOrderDifference
│ │ │ │ alg ┼ StandardisedValue
│ │ │ │ │ mv ┼ MeanValue
│ │ │ │ │ │ w ┴ nothing
│ │ │ │ │ sv ┼ StdValue
│ │ │ │ │ │ w ┼ nothing
│ │ │ │ │ │ corrected ┴ Bool: true
│ slv ┼ nothing
│ wb ┼ WeightBounds
│ │ lb ┼ Float64: 0.0
│ │ ub ┴ Float64: 1.0
│ fees ┼ nothing
│ sets ┼ nothing
│ wf ┼ IterativeWeightFinaliser
│ │ iter ┴ Int64: 100
│ brt ┼ Bool: false
│ cle_pr ┼ Bool: true
│ strict ┴ Bool: false
params ┼ SchurComplementParams
│ r ┼ Variance
│ │ settings ┼ RiskMeasureSettings
│ │ │ scale ┼ Float64: 1.0
│ │ │ ub ┼ nothing
│ │ │ rke ┴ Bool: true
│ │ sigma ┼ nothing
│ │ chol ┼ nothing
│ │ rc ┼ nothing
│ │ alg ┴ SquaredSOCRiskExpr()
│ gamma ┼ Float64: 0.5
│ pdm ┼ Posdef
│ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton
│ │ kwargs ┴ @NamedTuple{}: NamedTuple()
│ alg ┼ MonotonicSchurComplement
│ │ N ┼ Int64: 10
│ │ tol ┼ Float64: 0.0001
│ │ iter ┼ nothing
│ │ strict ┴ Bool: false
│ flag ┴ Bool: true
fb ┴ nothingMathematical definition
When splitting cluster
Where:
: Schur complement of the covariance block . , , , : Covariance sub-blocks corresponding to the partition of cluster into and .
The bisection weight
Related
PortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(
opt::SchurComplementHierarchicalRiskParity
) -> AnyReturn whether the SchurComplementHierarchicalRiskParity requires previous portfolio weights.
Related
sourcePortfolioOptimisers.port_opt_view Method
port_opt_view(
sh::SchurComplementHierarchicalRiskParity,
i,
X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
args...
) -> SchurComplementHierarchicalRiskParityReturn a view of SchurComplementHierarchicalRiskParity sh sliced to asset indices i.
Related
sourcePortfolioOptimisers.optimise Function
optimise(sh::SchurComplementHierarchicalRiskParity{<:Any, <:Any, Nothing},
rd::ReturnsResult = ReturnsResult(); dims::Int = 1, kwargs...) -> SchurComplementHierarchicalRiskParityResultRun the Schur Complement Hierarchical Risk Parity portfolio optimisation.
Arguments
sh: The Schur complement hierarchical risk parity optimiser to use.rd: The returns result to use. Ifisa(sh.opt.pe, AbstractPriorResult),rdis not necessary if doing a standalone optimisation, but may be required/desired by fallbacks and/or clusterisation.dims: The dimension along which observations advance in time.kwargs: Additional keyword arguments passed to the optimisation function.
Related
source