# Base-Date/Base-Value Initialization

`D03-F01-A01` · Index and Benchmark Engineering → Index Initialization and Continuity · archetype `record-transform` · difficulty 2/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/index-initialization-and-continuity/base-date-base-value-initialization/
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/index-initialization-and-continuity/base-date-base-value-initialization";
```

## Signature

```ts
calculate(data)
```

Sets an index running: pick a base date and a base level, and the divisor follows from the market value on that date. Everything else in index construction is maintenance of this one relationship.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ constituents: Constituent[]; baseLevel: number; baseDate: string }` | yes | `constituents` supply the market value at the base date. `baseLevel` is an arbitrary convention — 100 and 1000 are both common — and only fixes the scale. |

## Returns

`{ marketValue, divisor, indexLevel }`

The base market value, the divisor derived from it, and the level — which by construction equals `baseLevel` on day one.

## Errors

- When baseLevel is not positive or the market value is zero — throws

## Complexity

Time `O(n)`, space `O(1)`.

## 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
{
  "constituents": [
    {
      "id": "ALFA",
      "price": 50,
      "shares": 1000,
      "floatFactor": 0.8,
      "fx": 1
    },
    {
      "id": "BETA",
      "price": 80,
      "shares": 600,
      "floatFactor": 0.75,
      "fx": 1
    },
    {
      "id": "GAMMA",
      "price": 40,
      "shares": 1200,
      "floatFactor": 0.9,
      "fx": 1
    }
  ],
  "baseLevel": 1000,
  "baseDate": "2026-01-02"
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 3 fields: marketValue, divisor, indexLevel

```json
{
  "marketValue": 119200,
  "divisor": 119.2,
  "indexLevel": 1000
}
```

## 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/index-initialization-and-continuity/base-date-base-value-initialization/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/index-and-benchmark-engineering/index-initialization-and-continuity/base-date-base-value-initialization/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
