Asset Phylogeny
PortfolioOptimisers.asset_phylogeny — Function
asset_phylogeny(w::VecNum, X::MatNum)Compute the asset phylogeny score of the weights w on the phylogeny matrix X.
The score is the share of the gross weight of all pairs that the related pairs hold. It is the percentage invested in connected assets of Equation 13.7 of [12],
\[\begin{align} \mathrm{CA}(\boldsymbol{x}) &= \dfrac{\boldsymbol{1}_n^{\intercal} \left(\mathbf{B}_{1,\,l} \odot \lvert \boldsymbol{x}\boldsymbol{x}^{\intercal} \rvert\right) \boldsymbol{1}_n}{\boldsymbol{1}_n^{\intercal} \lvert \boldsymbol{x}\boldsymbol{x}^{\intercal} \rvert \boldsymbol{1}_n}\,, \end{align}\]
Where:
- $\mathbf{B}_{1,\,l}$: Phylogeny matrix from
phylogeny_matrix. - $\odot$: Hadamard, element-wise product.
- $\boldsymbol{x}$: Portfolio weight vector.
- $\boldsymbol{1}_n$: Column vector of ones of length $n$.
A pair of assets that are not related adds nothing, and a pair adds nothing when either weight is zero. A w of zeros gives NaN, because the denominator is zero.
Algorithm
- Take the absolute value of the outer product of
wwith itself. The resultawis the gross weight of every pair. - Take the dot product of
Xandaw, which adds up the gross weight of the related pairs. - Divide by the sum of
aw, and return the share invested in related assets.
Arguments
w: Portfolio weight vector.X: Phylogeny matrix.
Returns
p::Number: Asset phylogeny score.
Related
References
- [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 13.1.5.2, Equation 13.7.
asset_phylogeny(pl::PhylogenyResult{<:MatNum}, w::VecNum, args...;
kwargs...)Compute the asset phylogeny score of the weights w on a precomputed phylogeny matrix.
The method calls asset_phylogeny(w, pl.X). It accepts args and kwargs and does not read them, so a caller can pass a precomputed result where it passes an estimator and its data.
Arguments
pl::PhylogenyResult{<:MatNum}: Precomputed phylogeny matrix.w::VecNum: Portfolio weight vector.args...: Positional arguments. The method does not read them.kwargs...: Keyword arguments. The method does not read them.
Returns
score::Number: Asset phylogeny score.
Related
asset_phylogeny(cle::NwE_ClE_Cl,
w::VecNum, X::MatNum; dims::Int = 1, kwargs...)Compute the asset phylogeny score of the weights w on the phylogeny matrix that cle builds from X.
Algorithm
- Build the phylogeny matrix from
Xwithphylogeny_matrix. - Score
wagainst that matrix withasset_phylogeny.
Arguments
cle: Network estimator, clustering estimator, or clustering result.w: Portfolio weight vector.X: Data matrixobservations × assetsif thedimskeyword does not exist ordims = 1,assets × observationswhendims = 2.dims: Dimension along which the computation runs.kwargs...: Additional keyword arguments.
Returns
p::Number: Asset phylogeny score.
Related
asset_phylogeny(pl::NwE_ClE_Cl,
w::VecNum, pr::AbstractPriorResult; kwargs...)Compute the asset phylogeny score for a portfolio allocation using a phylogeny estimator or clustering result and a prior result.
This function computes the phylogeny matrix from the asset returns in the prior result using the specified phylogeny estimator or clustering result, then evaluates the asset phylogeny score for the given portfolio weights. The asset phylogeny score quantifies the degree of phylogenetic (network or cluster-based) structure present in the portfolio allocation.
Algorithm
- Pick the asset returns matrix
Xfrom the source that the reader states,returns_source, withreturns_matrix_picker. Refuse a gap inXthat a plain graph reader cannot read, withassert_graph_readable. - Call the asset-returns method of
asset_phylogenywithX, passing both results on asprandrdanddims = 1last, and return the score it produces.
Arguments
pl: Phylogeny estimator or clustering result used to compute the phylogeny matrix.w: Portfolio weights vector.pr: Prior result or returns result. Both carry the asset returns matrixX, so either can supply it.rd: The returns result to use. Read forXunder the source of the reader, and passed on to the estimator tree.iv: Optional implied volatility matrix,observations × assets, read by anImpliedVolatilityestimator in the tree. The estimator receives the last rows ofiv, one for each row of the pickedX, throughimplied_volatility_picker, so a prior that keeps fewer rows than the returns data still pairs each row of itsXwith the implied volatility of the same observation.kwargs...: Additional keyword arguments passed to the phylogeny matrix computation. An unknown keyword raises aMethodError, seegraph_verb_keywords.
Returns
score::Number: Asset phylogeny score.
Related
phylogeny_matrixAbstractPhylogenyEstimatorAbstractClusteringResultAbstractPriorResultPr_RRreturns_matrix_pickerasset_phylogeny: The asset-returns methods this one delegates to. They build the phylogeny matrix, add up the gross weight of the related pairs, and divide by the gross weight of every pair. That is where the score's closed form and its numbered steps are stated.
References
- [12]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).