liveBook · Manning

Recursive bisection

As explained in Build a Robo-Advisor with Python (From Scratch)

Recursive bisection is a portfolio-weighting technique that repeatedly splits ordered asset groups into two parts and adjusts their weights according to the variances of their subportfolios.

Recursive bisection computes hierarchical risk-parity weights after assets have been ordered by a correlation-based hierarchy. It repeatedly divides each ordered cluster into left and right subclusters, then assigns relatively more weight to the side with lower estimated variance. section 11.2.4 section 11.2.4

The weighting procedure is iterative:

  • Start every ordered asset with weight 1 and treat the complete ordering as one cluster. section 11.2.4
  • Split every cluster containing multiple assets into two halves. section 11.2.4
  • Estimate each half's variance using inverse-variance weights within its covariance submatrix. section 11.2.4
  • Set alpha to left variance divided by total two-cluster variance; multiply left weights by 1-alpha and right weights by alpha, then continue splitting. section 11.2.4

Eight-asset HRP allocation

Applied to VV, VB, AGG, VEA, BNDX, VWO, EMB, and DJP, the procedure produces its largest weights for BNDX (0.555) and AGG (0.302), with much smaller allocations to several equity assets. section 11.2.4 section 11.2.4

Listing 11.9 Recursive bisection algorithm
weights = pd.Series(1, index=ordering)
indices = [ordering.index]
while len(indices) > 0:
    indices = split_indices(indices)   #1
    for i in range(0, len(indices), 2):
        i_left, i_right = indices[i], indices[i + 1]
        left_var = calc_cluster_variance(cov, ordering[i_left])   #2
        right_var = calc_cluster_variance(cov, ordering[i_right])    #3
        
                
        alpha = left_var / (left_var + right_var)   #4
        weights[ordering[i_left]] *= 1 - alpha   #5
        weights[ordering[i_right]] *= alpha

The algorithm listing shows the split loop, cluster-variance calculations, and multiplicative weight updates. section 11.2.4

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Implements repeated splits, inverse-variance cluster estimates, and variance-based weight updates without detailing further optimization.
Examples
Uses eight ETF tickers and reports resulting weights and portfolio risk contributions.
What it assumes
Assumes an asset ordering from clustering and an annualized covariance matrix before weighting begins.
What you can do after
Apply it via Python to compute hierarchical risk-parity portfolio weights from ordered assets and a covariance matrix.
How it connects
Connects hierarchical risk parity with hierarchical clustering, correlation matrices, covariance matrices, and risk contributions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.