# Equal Risk Contribution

`D14-F02-A02` · Portfolio Construction → Risk Allocation · archetype `record-transform` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/portfolio-construction/risk-allocation/equal-risk-contribution/
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 { equalRiskContributionWeights } from "fintech-algorithms/portfolio-construction/risk-allocation/equal-risk-contribution";
```

## Signature

```ts
equalRiskContributionWeights(assetIds, covariance)
```

Solves for the weights that give every asset the same contribution to portfolio volatility, which equal capital weights do not.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `assetIds` | `readonly unknown[]` | yes |  |
| `covariance` | `readonly unknown[]` | yes |  |

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`assetIds`:

```json
["A", "B", "C"]
```

`covariance`:

```json
[
  [0.01, 0.016, 0.0015],
  [0.016, 0.04, -0.006],
  [0.0015, -0.006, 0.0225]
]
```

### Call

```ts
equalRiskContributionWeights(assetIds, covariance)
```

### Returns

object with 13 fields: assetIds, weights, componentRiskContributions, componentRiskShares, portfolioVariance, portfolioVolatility, sumWeights, riskShareResidual, …

```json
{
  "assetIds": ["A", "B", "C"],
  "weights": [0.3778302517370716, 0.23412526094592215, 0.3880444873170063],
  "componentRiskContributions": [0.031952220115817255, 0.03195222012249683, 0.031952220117888716],
  "componentRiskShares": [0.3333333333029024, 0.33333333337258536, 0.3333333333245123],
  "portfolioVariance": 0.00918849933464442,
  "portfolioVolatility": 0.0958566603562028,
  "sumWeights": 1,
  "riskShareResidual": 3.925204605792487e-11,
  "iterations": 20,
  "method": "equal-risk-contribution",
  "solver": "cyclical-coordinate-descent-volatility-eq7",
  "covarianceScale": 0.04,
  "status": "ok"
}
```

## Verification and provenance

Tier: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

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.2.
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/portfolio-construction/risk-allocation/equal-risk-contribution/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/portfolio-construction/risk-allocation/equal-risk-contribution/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/portfolio-construction/llms.txt
