Release 1.0.0: robust rtsafe solver, native C + Brent, full finance toolkit - #36
Merged
Conversation
…oolkit Revive and expand the gem around a safeguarded-Newton (rtsafe) solver. Solvers - New default `rtsafe` (safeguarded Newton): brackets the root, then a Newton or bisection step per iteration. Robust on long maturities, low rates, and returns near -100%; reports non-convergence instead of a wrong number. - Optional native C build (`method: :rtsafe_c`), best-effort: falls back to pure Ruby when no compiler is present (`Xirr::NATIVE`). - Optional derivative-free `:brent` (Brent over rtsafe's bracketing) — ties rtsafe and can win on very large cashflows. - Reimplemented `:newton_method` in plain Ruby (dropped deprecated bigdecimal/newton); `:bisection` kept. Dropped the bigdecimal dependency (Float). Finance toolkit (ported from finance-elixir) - Xirr::TVM, Xirr::Rates, Xirr::Bonds, Xirr::Depreciation, Xirr::Returns, plus periodic Xirr.irr/npv/mirr and Cashflow#xnpv / #mirr. Correctness & API - `xirr!` raises on failure; no silent 0.0 when a rate exists. - Fixed option precedence (raise_exception:false override), a per-call period leak into xnpv/mirr, and stale memoized dates after `<<`. - Rewrote irr_guess with proper guards. Housekeeping - Removed defunct Travis/Coveralls; added GitHub Actions CI and benchmark/. - Fixed a long-standing wrong value in the README example. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015wqC1PNHy3mMMKUTDyyxqN
This was referenced Jul 5, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1.0.0 — a revival
Centered on a more robust solver, with a much wider feature set.
Solvers
rtsafe(safeguarded Newton): brackets the root, then takes a Newton step when it stays inside the bracket and a bisection step otherwise. Converges on flows the old Newton/bisection pair failed on — long maturities, low rates, returns near −100% — and reports non-convergence instead of a wrong number.method: :rtsafe_c), best-effort: falls back to pure Ruby when no compiler is available (Xirr::NATIVE).:brent— derivative-free Brent's method over rtsafe's bracketing; ties rtsafe and pulls ahead on very large cashflows.:newton_methodreimplemented in plain Ruby (dropped the deprecatedbigdecimal/newton);:bisectionretained.bigdecimaldependency dropped — results areFloat.Finance toolkit (ported from finance-elixir)
Xirr::TVM,Xirr::Rates,Xirr::Bonds,Xirr::Depreciation,Xirr::Returns, plus periodicXirr.irr/npv/mirrandCashflow#xnpv/#mirr.Correctness & API
xirr!raises on failure; no more silent0.0when a rate exists.raise_exception: falseoverride), a per-callperiod:leak intoxnpv/mirr, and stale memoized dates after<<.irr_guesswith proper guards.Housekeeping
benchmark/.All green: 116 runs, 593 assertions, 0 failures.
🤖 Generated with Claude Code
https://claude.ai/code/session_015wqC1PNHy3mMMKUTDyyxqN