# Volatility-Control Index

`D03-F05-A03` · Index and Benchmark Engineering → Strategy Indices · archetype `record-transform` · difficulty 5/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/strategy-indices/volatility-control-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/strategy-indices/volatility-control-index";
```

## Signature

```ts
calculate(data)
```

Scales exposure to hold realised volatility near a target, cutting it when markets get rough. Exposure is set from *trailing* volatility, so the mechanism always acts after the fact — it dampens rather than avoids.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ returns: number[]; lookback: number; annualization: number; targetVolatility: number; maxExposure: number; cashReturn: number; baseLevel: number }` | yes | `lookback` is the realised-volatility window and `annualization` the scaling factor (252 for daily data). `maxExposure` caps leverage when volatility is low. `baseLevel` is the index value at the start of the series; it scales the level but never the returns. |

## Returns

`{ exposures, strategyReturns, levels, endingLevel }`

The exposure actually taken each day alongside the returns — the exposure path is what explains the strategy's behaviour.

## Errors

- When lookback < 1, or targetVolatility is not positive — throws

## Complexity

Time `O(n × lookback)`, 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
{
  "returns": [0.004, -0.003, 0.005, 0.002, -0.012, 0.015],
  "lookback": 4,
  "annualization": 252,
  "targetVolatility": 0.1,
  "maxExposure": 1.5,
  "cashReturn": 0.0001,
  "baseLevel": 1000
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 4 fields: exposures, strategyReturns, levels, endingLevel

```json
{
  "exposures": [1, 1, 1, 1, 1.5, 0.84685],
  "strategyReturns": [0.004, -0.003, 0.005, 0.002, -0.01805, 0.012718],
  "levels": [1000, 1004, 1000.988, 1005.99294, 1008.004926, 989.810437],
  "endingLevel": 1006.077264
}
```

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