# Dividend-Yield-Weighted Index

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

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

## Signature

```ts
calculate(data)
```

Weight by dividend yield. Straightforward arithmetic with a well-known failure mode: yield rises as price falls, so the construction naturally overweights companies in distress.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ ids: string[]; dividendYields: number[] }` | yes | Constituent ids and their yields, expressed consistently as fractions or percentages. |

## Returns

`{ ids, weights, weightedYield }`

Weights and the resulting portfolio yield.

## Errors

- When a yield 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", "E"],
  "dividendYields": [0.035, 0.02, 0.05, 0.015, 0.03]
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 3 fields: ids, weights, weightedYield

```json
{
  "ids": ["A", "B", "C", "D", "E"],
  "weights": [0.233333, 0.133333, 0.333333, 0.1, 0.2],
  "weightedYield": 0.035
}
```

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