# Capped Free-Float Market-Cap Index

`D03-F02-A04` · Index and Benchmark Engineering → Weighting and Capping · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/weighting-and-capping/capped-free-float-market-cap-index/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { calculate } from "fintech-algorithms/index-and-benchmark-engineering/weighting-and-capping/capped-free-float-market-cap-index";
```

## Signature

```ts
calculate(data)
```

Float weighting with a ceiling on any single constituent. Regulation and mandate limits require it, and the redistribution is subtler than it looks: capping one name lifts the others, which can push a second name over the cap.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ ids: string[]; marketValues: number[]; cap: number }` | yes | `cap` is the maximum weight any one constituent may hold, as a fraction. The routine iterates until every weight is compliant. |

## Returns

`{ ids, weights, cap, iterations, maxWeight, weightSum }`

Compliant weights plus `iterations` and `maxWeight`, so the redistribution can be checked rather than assumed to have converged.

## Errors

- When cap is not between 0 and 1 — throws
- When the cap is mathematically unsatisfiable — cap × count < 1 — throws

## Complexity

Time `O(n × iterations)`, space `O(n)`.

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`data`:

```json
{
  "ids": ["A", "B", "C", "D", "E"],
  "marketValues": [48, 24, 14, 9, 5],
  "cap": 0.3
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 6 fields: ids, weights, cap, iterations, maxWeight, weightSum

```json
{
  "ids": ["A", "B", "C", "D", "E"],
  "weights": [0.3, 0.3, 0.2, 0.128571, 0.071429],
  "cap": 0.3,
  "iterations": 3,
  "maxWeight": 0.3,
  "weightSum": 1
}
```

## Verification and provenance

Tier: **verified** (via input-expected).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/index-and-benchmark-engineering/weighting-and-capping/capped-free-float-market-cap-index/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/index-and-benchmark-engineering/weighting-and-capping/capped-free-float-market-cap-index/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/llms.txt
