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

Simple Interest

Install and import#

bash
npm install fintech-algorithms
ts
import { simpleInterest } from "fintech-algorithms/foundations/financial-arithmetic-time-value-and-returns/simple-interest";

Signature#

simpleInterest(input)

Computes interest that accrues on the original principal only, never on interest already earned, and the balance that leaves at the end.

Parameters#

NameTypeNotes
inputD00InputA plain object. Every F02 topic first reads principal, rate and periods and validates them before any per-topic branch runs. This topic uses exactly those three and reads no further keys. rate is the rate per period, matching the unit periods is counted in.

Returns#

{ interest: number; endingValue: number }

interest is principal * rate * periods and endingValue is the principal plus that interest.

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

Complexity: time O(1), space O(1).

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#

simpleInterest(input)

Returns#

object with 2 fields: interest, endingValue

{
  "interest": 150,
  "endingValue": 1150
}

Diagrams#

Simple Interest — concept anatomy
Simple Interest — lesson map
Simple Interest — mistake contrast

Calculation flow#

Simple Interest — four-part map
flowchart LR
    A["Name the input"] --> B["Apply: interest = P x r x t; amount = P x (1 + r x t)"]
    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_INTEREST - Interest — U.S. Securities and Exchange Commission
  • CFA_TVM - Time Value of Money in Finance — CFA Institute
  • Author-derived and synthetic boundary

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