Skip to content
All library documents

Iterative Market-Cap Weighting Under a Maximum Index Cap

Article Quant Q&A · Author: Corey

Summary

This document explains how to allocate a market-cap-weighted crypto index when no constituent may exceed a chosen maximum weight. It presents a sequential calculation: start with each asset’s share of total market value, scale that share by the weight and market value still available, and cap the result. Updating the remaining totals redistributes weight across later assets without recursive calls.

An alternative iterative procedure caps overweight assets, calculates the unallocated weight, and redistributes it among uncapped assets in proportion to market value until no further assets breach the limit. The document provides Java code for the sequential approach and pseudocode for the iterative one, but no worked numerical example or performance evidence. The code assumes assets are processed in a suitable order and that the cap and eligible asset set allow a valid allocation; those conditions are not discussed in detail. The pseudocode is explicitly untested, so implementation details should be checked before use.

Key ideas

  • A maximum constituent weight can limit how much any one asset influences a market-cap-weighted index.
  • The sequential method reallocates weight using the remaining market value and remaining index weight.
  • An iterative alternative caps overweight constituents and redistributes their excess proportionally among uncapped assets.
  • The document offers implementation sketches but no numerical validation, and its pseudocode is marked as untested.

Tags

Full text
# Algorithm for calculating Capped Index weightings


# Algorithm for calculating Capped Index weightings












I'm trying to build a Capped Index Fund of crypto currencies. As Investopedia explains, a "Capped index is an equity index that has a limit on the weight of any single security. Thus, a capped index sets a maximum percentage on the relative weighting of a component that is determined by its market capitalization. The rationale behind a capped index is to prevent any single security from exerting a disproportionate influence on an index."

I need an algorithm or a spreadsheet that calculates the capped weightings of the currencies. Page 6 of Morningstar Index Calculation Methodology seems to discuss the formulas I need to calculate the capped weightings but I'm having trouble translating these into an code.

As I think about the algorithm needed, it seems some sort of nested or recursive loop would be necessary. Every time the weighting of one currency is capped, the weightings of the remaining currencies need to go up proportionally. Perhaps this could be accomplished by recursively calling the capping algorithm on the remaining currencies with a modified cap for each recursive call. Or maybe I'm confused and over thinking it.

Here's a spreadsheet based on my first attempt to solve this.

Is anyone aware of some sample code or a spreadsheet that accomplishes this? Anyone want to take a crack as some pseudo code?

Many thanks.

## Answer by Corey (score 2, accepted)

https://quant.stackexchange.com/a/39848

I figured it out! See the second tab of my spreadsheet for the solution.

And for what it's worth, here's my Java code. No recursion needed!

```
final double totalMarketCap = filteredTickers.stream().mapToDouble(ticker -> ticker.getMarketCapUSD().doubleValue()).sum();
double cappedRemaining = 1d;
double marketRemaining = 1d;
for (CoinMarketCapTicker ticker : filteredTickers) {
    double marketPercentage = ticker.getMarketCapUSD().doubleValue() / totalMarketCap;
    double uncappedPercentage = marketPercentage * cappedRemaining / marketRemaining;
    double cappedPercentage = Math.min(uncappedPercentage, _indexCap);

    _indexTickers.add(new IndexTicker(ticker, marketPercentage, cappedPercentage));

    marketRemaining -= marketPercentage;
    cappedRemaining -= cappedPercentage;
}
```

## Answer by Alex C (score 0)

https://quant.stackexchange.com/a/39847

I think it can be done iteratively.

> For each security you need a boolean variable Capped which is 1 if the security is currently at its cap or 0 otherwise. Initially Capped[i]=0 for all securities i and initially Weight[i]=the market value based weight of security i. Then you go onto a loop: You set Finished to TRUE First you examine all uncapped securities and if Weight[i]> Cap you set Weight[i]=Cap; Capped[i]=1 and Finshed=FALSE Second you compute the free (or uncapped) weight, which is equal to 1 minus the sum of the weights of the capped securities. Third for all uncapped securities, you assign them a weight proportional to their market value and such that their sum is equal to the free weight computed in step 2. If FINSHED=FALSE (meaning that some security was capped in this iteration) you go back to the top of this loop, else you exit this loop.

(A word of warning, however, this pseudo-code has not been debugged).

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.