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, measured over the returns strictly before the current one, as a sample standard deviation with an n-1 denominator. annualization is the periods-per-year count (252 for daily data) that multiplies the sample variance before the square root. maxExposure caps exposure when volatility is low and is also the exposure used when a window's realised volatility is exactly zero. baseLevel is the index value at the start of the series; it scales the level but never the returns. There is no exposure floor, no rebalance band or trigger, and no separate warm-up parameter: the first lookback observations are given exposure 1 by convention.

Returns#

{ exposures, strategyReturns, levels, endingLevel }

The exposure actually taken each period alongside the returns — the exposure path is what explains the strategy's behaviour. No turnover, trade, or cost figure is produced.

Errors#

  • When lookback < 2, or returns has no more than lookback observations — throws
  • When targetVolatility, maxExposure, or annualization is not positive — throws
  • When a strategy return drives the index level to zero or below — 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#