fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Dividend-Yield-Weighted Index

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#

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#

NameTypeNotes
data{ ids: string[]; dividendYields: number[] }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#

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

Input#

data
{
  "ids": ["A", "B", "C", "D", "E"],
  "dividendYields": [0.035, 0.02, 0.05, 0.015, 0.03]
}

Call#

calculate(data)

Returns#

object with 3 fields: ids, weights, weightedYield

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

Diagrams#

Dividend-Yield-Weighted Index — article hero
Dividend-Yield-Weighted Index — failure guard
Dividend-Yield-Weighted Index — worked example

Calculation flow#

Dividend-Yield-Weighted Index calculation flow
flowchart LR
    A["Point-in-time inputs"] --> B["Validate units and timing"]
    B --> C{"Contract feasible?"}
    C -->|No| D["Reject with reason"]
    C -->|Yes| E["Calculate Dividend-Yield-Weighted Index"]
    E --> F["Recompute invariants"]
    F --> G{"Checks pass?"}
    G -->|No| D
    G -->|Yes| H["Publish audited output"]
Dividend-Yield-Weighted Index methodology state
stateDiagram-v2
    [*] --> FrozenInputs
    FrozenInputs --> Validated: contract passes
    FrozenInputs --> Rejected: missing or infeasible
    Validated --> Calculated: apply named rule
    Calculated --> Audited: invariants pass
    Calculated --> Rejected: invariant fails
    Audited --> Published: version and timestamp recorded
    Published --> Revised: approved correction
    Revised --> FrozenInputs: rebuild from retained source state

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Alternative Weighting family#