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.