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

Volatility-Control Index

Install and import#

bash
npm install fintech-algorithms
ts
import { calculate } from "fintech-algorithms/index-and-benchmark-engineering/strategy-indices/volatility-control-index";

Signature#

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#

NameTypeNotes
data{ returns: number[]; lookback: number; annualization: number; targetVolatility: number; maxExposure: number; cashReturn: number; baseLevel: number }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#

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

Input#

data
{
  "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#

calculate(data)

Returns#

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

{
  "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
}

Diagrams#

Volatility-Control Index — article hero
Volatility-Control Index — failure guard
Volatility-Control Index — worked example

Calculation flow#

Volatility-Control 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 Volatility-Control Index"]
    E --> F["Recompute invariants"]
    F --> G{"Checks pass?"}
    G -->|No| D
    G -->|Yes| H["Publish audited output"]
Volatility-Control 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 Strategy Indices family#