Log Return
Install and import#
npm install fintech-algorithmsimport { logReturn } from "fintech-algorithms/foundations/financial-arithmetic-time-value-and-returns/log-return";Signature#
logReturn(input)Takes the natural logarithm of the growth ratio between a starting and an ending value, and converts it back to show the two are the same move.
Parameters#
| Name | Type | Notes |
|---|---|---|
input | D00Input | A plain object. Every F02 topic first reads principal, rate and periods and validates them before any per-topic branch runs. This topic then reads startValue and endValue, which must both be strictly positive; principal, rate and periods are validated but not used. |
Returns#
{ logReturn: number; recoveredSimpleReturn: number }
logReturn is the natural log of endValue / startValue. recoveredSimpleReturn exponentiates it back and subtracts 1, giving the matching simple return.
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
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#
{
"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#
logReturn(input)Returns#
object with 2 fields: logReturn, recoveredSimpleReturn
{
"logReturn": 0.09531017980432493,
"recoveredSimpleReturn": 0.10000000000000009
}Diagrams#
Calculation flow#
Log Return — four-part map
flowchart LR
A["Name the input"] --> B["Apply: log return = ln(ending value / starting value)"]
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.
References#
- NIST_LOG - NIST Dataplot: Exponential and Logarithmic Functions — Institutional source
- CFA_QM - CFA Institute Quantitative Methods Study Session — CFA Institute
- Author-derived and synthetic boundary