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

Holding-Period and Cumulative Return

Install and import#

bash
npm install fintech-algorithms
ts
import { holdingPeriodAndCumulativeReturn } from "fintech-algorithms/foundations/financial-arithmetic-time-value-and-returns/holding-period-return";

Signature#

holdingPeriodAndCumulativeReturn(input)

Chains a series of period returns into the single growth factor they compound to, and applies that factor to a starting value.

Parameters#

NameTypeNotes
inputD00InputA plain object. Every F02 topic first reads principal, rate and periods and validates them before any per-topic branch runs. Before reaching this branch the engine also rejects a startValue or endValue that is zero or negative (omitting them entirely is not caught, because Number(undefined) is NaN), and returns to be a non-empty array of finite numbers none of which is at or below -1. The calculation itself uses returns and startValue; endValue, principal, rate and periods are validated but not used.

Returns#

{ growthFactor: number; cumulativeReturn: number; endingValue: number }

growthFactor is the product of 1 + r across the series, cumulativeReturn is that factor less 1, and endingValue is startValue grown by the factor.

Errors#

  • When input is not a plain object — throws TypeError
  • When principal is negative, periods is negative, or rate is at or below -1 — throws RangeError
  • When startValue or endValue is zero or negative — throws RangeError
  • When returns is missing, empty, not an array, or contains a non-finite number — throws RangeError
  • When any entry of returns is at or below -1, a loss of 100% or worse — throws RangeError

Complexity: time O(n), 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#

input
{
  "principal": 1000,
  "rate": 0.05,
  "periods": 3,
  "compoundsPerPeriod": 12,
  "futureValue": 1200,
  "cashFlows": [-1000, 400, 400, 400],
  "startValue": 100,
  "endValue": 110,
  "returns": [0.1, -0.05, 0.08],
  "frequency": 12,
  "periodicReturn": 0.01
}

Call#

holdingPeriodAndCumulativeReturn(input)

Returns#

object with 2 fields: growthFactor, cumulativeReturn

{
  "growthFactor": 1.1286,
  "cumulativeReturn": 0.12860000000000005
}

Diagrams#

Holding-Period and Cumulative Return — concept anatomy
Holding-Period and Cumulative Return — lesson map
Holding-Period and Cumulative Return — mistake contrast

Calculation flow#

Holding-Period and Cumulative Return — four-part map
flowchart LR
    A["Name the input"] --> B["Apply: cumulative return = (1+r1)(1+r2)...(1+rn) - 1"]
    B --> C["Check units and boundary"]
    C --> D["Explain the output"]

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#

  • INVESTOR_RETURN - Annual Return — U.S. Securities and Exchange Commission
  • CFA_QM - CFA Institute Quantitative Methods Study Session — CFA Institute
  • Author-derived and synthetic boundary

The rest of the Financial Arithmetic, Time Value, and Returns family#