# Net Total-Return Index

`D03-F04-A03` · Index and Benchmark Engineering → Return Variants · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/return-variants/net-total-return-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/return-variants/net-total-return-index";
```

## Signature

```ts
calculate(data)
```

Reinvests dividends after withholding tax. Over a decade the gap from the gross variant is large enough that quoting the wrong one materially misstates performance — and both are published under nearly the same name.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ prices: number[]; dividends: number[]; withholdingRates: number[]; baseLevel: number }` | yes | `withholdingRates` is per observation because the rate depends on the domicile pairing and changes with treaty. `baseLevel` is the index value at the start of the series; it scales the level but never the returns. |

## Returns

`{ returns, levels, endingLevel }`

Total returns with dividends reinvested net of withholding.

## Errors

- When a withholding rate falls outside 0…1 — 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
{
  "prices": [100, 102, 99, 101, 103, 104],
  "dividends": [0, 0, 3, 0, 0, 1],
  "withholdingRates": [0, 0, 0.25, 0, 0, 0.25],
  "baseLevel": 1000
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 3 fields: returns, levels, endingLevel

```json
{
  "returns": [0.02, -0.007353, 0.020202, 0.019802, 0.01699],
  "levels": [1000, 1020, 1012.5, 1032.954545, 1053.409091, 1071.306818],
  "endingLevel": 1071.306818
}
```

## 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/return-variants/net-total-return-index/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/index-and-benchmark-engineering/return-variants/net-total-return-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
