# Equal-Risk-Contribution Index

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

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/alternative-weighting/equal-risk-contribution-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/alternative-weighting/equal-risk-contribution-index";
```

## Signature

```ts
calculate(data)
```

Risk parity: weights chosen so every constituent contributes the same share of total portfolio risk. Equal *risk*, not equal money — a volatile asset gets a smaller position.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ ids: string[]; covariance: number[][]; tolerance: number; maxIterations: number }` | yes | Solved iteratively; `tolerance` is the convergence threshold on risk-contribution dispersion and `maxIterations` the bound. |

## Returns

`{ ids, weights, riskContributionShares, volatility, iterations }`

The weights plus each constituent's realised risk share — which should be equal, and is reported so that can be verified rather than assumed.

## Errors

- When the covariance matrix is not square or not symmetric — 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"],
  "covariance": [
    [0.04, 0.006, 0.004],
    [0.006, 0.0225, 0.003],
    [0.004, 0.003, 0.01]
  ],
  "tolerance": 1e-8,
  "maxIterations": 1000
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 5 fields: ids, weights, riskContributionShares, volatility, iterations

```json
{
  "ids": ["A", "B", "C"],
  "weights": [0.230769, 0.307692, 0.461538],
  "riskContributionShares": [0.333333, 0.333333, 0.333333],
  "volatility": 0.094587,
  "iterations": 12
}
```

## 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/alternative-weighting/equal-risk-contribution-index/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/index-and-benchmark-engineering/alternative-weighting/equal-risk-contribution-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
