Skip to content

Release 1.0.0: robust rtsafe solver, native C + Brent, full finance toolkit - #36

Merged
tubedude merged 1 commit into
masterfrom
release/1.0.0
Jul 5, 2026
Merged

Release 1.0.0: robust rtsafe solver, native C + Brent, full finance toolkit#36
tubedude merged 1 commit into
masterfrom
release/1.0.0

Conversation

@tubedude

@tubedude tubedude commented Jul 5, 2026

Copy link
Copy Markdown
Owner

1.0.0 — a revival

Centered on a more robust solver, with a much wider feature set.

Solvers

  • New default 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.
  • Optional native C (method: :rtsafe_c), best-effort: falls back to pure Ruby when no compiler is available (Xirr::NATIVE).
  • Optional :brent — derivative-free Brent's method over rtsafe's bracketing; ties rtsafe and pulls ahead on very large cashflows.
  • :newton_method reimplemented in plain Ruby (dropped the deprecated bigdecimal/newton); :bisection retained. bigdecimal dependency dropped — results are 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 more 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/.
  • Corrected a long-standing wrong value in the README example.

All green: 116 runs, 593 assertions, 0 failures.

🤖 Generated with Claude Code
https://claude.ai/code/session_015wqC1PNHy3mMMKUTDyyxqN

…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
@tubedude
tubedude merged commit 3e0f4f3 into master Jul 5, 2026
3 checks passed
@tubedude
tubedude deleted the release/1.0.0 branch July 5, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant