Class: Xirr::RtSafeC
Overview
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
Methods included from Base
#initialize, #periods_from_start, #xnpv, #xnpv_derivative
Instance Method Details
#xirr(guess, options) ⇒ Float?
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/xirr/rtsafe_c.rb', line 21 def xirr(guess, ) limit = ( && [:iteration_limit]) || Xirr.config.iteration_limit start = (guess || cf.irr_guess).to_f rate = Xirr::Native.rtsafe(flows, start, Xirr.config.eps.to_f, limit) return nil if rate.nil? # Round before the floor check: a rate just above -1 can round down to it. rounded = rate.round(Xirr.config.precision) rounded <= -1.0 ? nil : rounded end |