Add function XIRR - #1701
Conversation
✅ Deploy Preview for hyperformula-dev-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Task linked: HF-76 Implement function XIRR |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7827c1e. Configure here.
Performance comparison of head (36c1465) vs base (4e302ff) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1701 +/- ##
===========================================
+ Coverage 97.14% 97.15% +0.01%
===========================================
Files 176 176
Lines 15333 15404 +71
Branches 3390 3409 +19
===========================================
+ Hits 14895 14966 +71
Misses 438 438
🚀 New features to boost your workflow:
|
marcin-kordas-hoc
left a comment
There was a problem hiding this comment.
LGTM — approving. Additive function, full i18n coverage across all packs, and the paired test suite (#21) is thorough. Two non-blocking notes:
1. epsMax convergence tolerance (nit, non-blocking). epsMax = 1e-10 is used as an absolute tolerance on the NPV. For cash flows in the millions, |npv| < 1e-10 is effectively unreachable, so convergence ends up resting entirely on the rate-delta check; for very small flows it can trip a touch early. The name also reads as a maximum, but it's a minimum tolerance — and the same constant backs three different thresholds (NPV, derivative singularity, rate-delta). Might be worth a relative NPV tolerance plus a large-magnitude test case, but nothing blocking here.
2. list-of-differences.md (question). XIRR has a couple of Excel-specific behaviors — 365-day year, and "the first date is the minimum" rather than requiring the dates to be sorted. Should we add an entry to docs/guide/list-of-differences.md, or is this considered fully Excel-consistent with nothing to note?
Nice work.

Summary
Implements the Excel
XIRRfunction (HF-76).XIRR(Values, Dates[, Guess])toFinancialPlugin— returns the internal rate of return for a schedule of cash flows that is not necessarily periodicGuessdefaults to0.1; solver uses Newton–Raphson with day-based discounting on a 365-day year0, and returns#NA!for single-cell or scalar argumentsXIRRin all language packs, updatesbuilt-in-functions.mdandCHANGELOG.mdfunction-xirr.spec.ts)Test plan
npm test— lint + unit + browserTypes of changes
Note
Low Risk
Additive built-in function in FinancialPlugin with localized names and documentation; no changes to auth, persistence, or core engine APIs.
Overview
Adds Excel-compatible
XIRR(Values, Dates[, Guess])for irregular cash-flow schedules, alongside existingIRRandXNPV.Implementation lives in
FinancialPlugin: aligned value/date ranges are sanitized (empty value cells →0, errors propagated, non-numeric →#VALUE!), with checks for length match, at least two flows, mixed signs, valid dates, andGuess > -1. The rate is solved with Newton–Raphson on day-based discounting using a 365-day year, including overshoot clamping when the iterate would fall at or below -1.XIRRis registered in all language packs, documented inbuilt-in-functions.md, noted inCHANGELOG.md, andAGENTS.mdgains a reminder to keep PR descriptions up to date.Reviewed by Cursor Bugbot for commit 36c1465. Bugbot is set up for automated code reviews on this repo. Configure here.