# Modified Market-Cap Index

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

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/weighting-and-capping/modified-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/modified-market-cap-index";
```

## Signature

```ts
calculate(data)
```

Applies an exponent to market value before weighting, compressing the gap between the largest and smallest members. An exponent of 1 is plain cap weighting and 0 is equal weighting; between them is a continuous dial.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ ids: string[]; marketValues: number[]; exponent: number }` | yes | `exponent` below 1 compresses the distribution; above 1 concentrates it further. |

## Returns

`{ ids, transformedValues, weights, exponent }`

The transformed values and resulting weights.

## Errors

- When a market value is negative — throws

## Complexity

Time `O(n)`, 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"],
  "marketValues": [64, 25, 9, 4],
  "exponent": 0.5
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 4 fields: ids, transformedValues, weights, exponent

```json
{
  "ids": ["A", "B", "C", "D"],
  "transformedValues": [8, 5, 3, 2],
  "weights": [0.444444, 0.277778, 0.166667, 0.111111],
  "exponent": 0.5
}
```

## 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/modified-market-cap-index/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/index-and-benchmark-engineering/weighting-and-capping/modified-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
