# Excess-Return Index

`D03-F04-A04` · 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/excess-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/excess-return-index";
```

## Signature

```ts
calculate(data)
```

Total return less a cash return, giving the return over funding. This is what a futures or swap position on the index actually earns, which is why structured products quote it.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ totalReturns: number[]; cashReturns: number[]; baseLevel: number }` | yes | Both series must cover identical periods; mismatched compounding frequencies are a silent error. `baseLevel` is the index value at the start of the series; it scales the level but never the returns. |

## Returns

`{ excessReturns, levels, endingLevel }`

Excess returns and the level series they generate.

## Errors

- When the two return series differ in length — 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
{
  "totalReturns": [0.005, -0.002, 0.008, 0.001, -0.004, 0.006],
  "cashReturns": [0.00015, 0.00015, 0.00016, 0.00016, 0.00016, 0.00017],
  "baseLevel": 1000
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 3 fields: excessReturns, levels, endingLevel

```json
{
  "excessReturns": [0.004849, -0.00215, 0.007839, 0.00084, -0.004159, 0.005829],
  "levels": [1000, 1004.849273, 1002.689171, 1010.548996, 1011.397722, 1007.19098],
  "endingLevel": 1013.061905
}
```

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