tubedude / xirr Goto Github PK
View Code? Open in Web Editor NEWCalculates IRR of a Cashflow, simillar to Excels, XIRR formula.
Home Page: https://rubygems.org/gems/xirr
License: MIT License
Calculates IRR of a Cashflow, simillar to Excels, XIRR formula.
Home Page: https://rubygems.org/gems/xirr
License: MIT License
Hi,
Are you planning to support Rails 6? If so, could you please make the adjustments.
Thanks a lot!
Specs:
master
branch.How to reproduce:
require "date"
values = [
[Date.parse("13 Dec 2022"), -10000.0],
[Date.parse("13 Dec 2022"), 8000.0],
[Date.parse("13 Dec 2022"), 2500.0],
[Date.parse("30 Jan 2023"), 1100.0]
]
cashflow = Xirr::Cashflow.new
values.each do |date, value|
cashflow << Xirr::Transaction.new(value, date: date)
end
cashflow.xirr
Possible cause:
Seems like Cashflow#irr_guess
is returning false
, and that value is then used on Xirr::Bisection.xirr
inside an array, which is called min
on it, causing a comparison to false.
Hi, would it be possible to upload a version to support rails 7/ruby 3.1.2?
First of all great gem! Love how flawless this runs on my machine. The calculation seem even more smooth than excels calculation of xirr.
I have troubles deploying it to heroku however. It runs smoothly in my local environment on Ruby 2.4.1. The server at Heroku however crashes when trying to load this gem.
Heroku is not the first host to fail at this. I had it on a vps server at a2hosting.com, which also crashed and wasn't able to load the gem. Once I disabled it my app was fine. So I am pretty sure it is not due to the specific environment of heroku. Without this gem my app runs remotely.
I would really like to use this gem, also remotely, please help! Thanks.
Here are the logs: (Please note that the crash happens at 2018-10-04T14:00:58.317322+00:00 heroku[web.1]: )
2018-10-04T13:52:07.440125+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
2018-10-04T13:52:07.440127+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2018-10-04T13:52:07.440128+00:00 app[web.1]: from bin/rails:9:in `<main>'
2018-10-04T14:00:38.937632+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-04T14:00:53.448485+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 26231 -e production`
2018-10-04T14:00:58.317322+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-04T14:00:58.303498+00:00 heroku[web.1]: Process exited with status 1
2018-10-04T14:00:58.245064+00:00 app[web.1]: sh: 1: gcc: not found
2018-10-04T14:00:58.245583+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:85:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'xirr'. (Bundler::GemRequireError)
2018-10-04T14:00:58.245589+00:00 app[web.1]: Gem Load Error is: error executing "gcc -shared -Wl,--compress-debug-sections=zlib -fPIC -O3 -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -L. -fstack-protector -rdynamic -Wl,-export-dynamic -I /app/vendor/ruby-2.4.1/include/ruby-2.4.0 -I /app/vendor/ruby-2.4.1/include/ruby-2.4.0/x86_64-linux -I /app/vendor/ruby-2.4.1/include -L/app/vendor/ruby-2.4.1/lib -o \"/app/.ruby_inline/ruby-2.4.0/Inline_Xirr__Base_e5418cc7a0340a20b564219237faf166.so\" \"/app/.ruby_inline/ruby-2.4.0/Inline_Xirr__Base_e5418cc7a0340a20b564219237faf166.c\" ": pid 8 exit 127
2018-10-04T14:00:58.245622+00:00 app[web.1]: Renamed /app/.ruby_inline/ruby-2.4.0/Inline_Xirr__Base_e5418cc7a0340a20b564219237faf166.c to /app/.ruby_inline/ruby-2.4.0/Inline_Xirr__Base_e5418cc7a0340a20b564219237faf166.c.bad
2018-10-04T14:00:58.245625+00:00 app[web.1]: Backtrace for gem load error is:
2018-10-04T14:00:58.245627+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/RubyInline-3.12.4/lib/inline.rb:618:in `build'
2018-10-04T14:00:58.245628+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/RubyInline-3.12.4/lib/inline.rb:856:in `inline'
2018-10-04T14:00:58.245630+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/xirr-0.6.0/lib/xirr/base.rb:31:in `<module:Base>'
2018-10-04T14:00:58.245631+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/xirr-0.6.0/lib/xirr/base.rb:4:in `<module:Xirr>'
2018-10-04T14:00:58.245633+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/xirr-0.6.0/lib/xirr/base.rb:1:in `<main>'
2018-10-04T14:00:58.245635+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2018-10-04T14:00:58.245641+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2018-10-04T14:00:58.245643+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
2018-10-04T14:00:58.245644+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2018-10-04T14:00:58.245645+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2018-10-04T14:00:58.245646+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
2018-10-04T14:00:58.245647+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
2018-10-04T14:00:58.245650+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2018-10-04T14:00:58.245648+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2018-10-04T14:00:58.245649+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/xirr-0.6.0/lib/xirr.rb:6:in `<main>'
2018-10-04T14:00:58.245651+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2018-10-04T14:00:58.245652+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
2018-10-04T14:00:58.245653+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2018-10-04T14:00:58.245654+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2018-10-04T14:00:58.245655+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:82:in `block (2 levels) in require'
2018-10-04T14:00:58.245656+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
2018-10-04T14:00:58.245657+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
2018-10-04T14:00:58.245658+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
2018-10-04T14:00:58.245659+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
2018-10-04T14:00:58.245660+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
2018-10-04T14:00:58.245661+00:00 app[web.1]: /app/config/application.rb:7:in `<main>'
2018-10-04T14:00:58.245662+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2018-10-04T14:00:58.245668+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2018-10-04T14:00:58.245669+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
2018-10-04T14:00:58.245670+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2018-10-04T14:00:58.245671+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2018-10-04T14:00:58.245672+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
2018-10-04T14:00:58.245673+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
2018-10-04T14:00:58.245674+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2018-10-04T14:00:58.245675+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:145:in `block in perform'
2018-10-04T14:00:58.245676+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
2018-10-04T14:00:58.245676+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
2018-10-04T14:00:58.245677+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
2018-10-04T14:00:58.245678+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
2018-10-04T14:00:58.245679+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
2018-10-04T14:00:58.245680+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
2018-10-04T14:00:58.245681+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
2018-10-04T14:00:58.245682+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
2018-10-04T14:00:58.245683+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2018-10-04T14:00:58.245684+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2018-10-04T14:00:58.245685+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
2018-10-04T14:00:58.245686+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2018-10-04T14:00:58.245687+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2018-10-04T14:00:58.245688+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
2018-10-04T14:00:58.245689+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
2018-10-04T14:00:58.245690+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2018-10-04T14:00:58.245691+00:00 app[web.1]: bin/rails:9:in `<main>'
2018-10-04T14:00:58.245692+00:00 app[web.1]: Bundler Error Backtrace:
2018-10-04T14:00:58.245693+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
2018-10-04T14:00:58.245694+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `each'
2018-10-04T14:00:58.245695+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:77:in `block in require'
2018-10-04T14:00:58.245696+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `each'
2018-10-04T14:00:58.245698+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler/runtime.rb:66:in `require'
2018-10-04T14:00:58.245698+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bundler-1.15.2/lib/bundler.rb:108:in `require'
2018-10-04T14:00:58.245699+00:00 app[web.1]: from /app/config/application.rb:7:in `<main>'
2018-10-04T14:00:58.245700+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2018-10-04T14:00:58.245701+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2018-10-04T14:00:58.245702+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
2018-10-04T14:00:58.245704+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2018-10-04T14:00:58.245705+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2018-10-04T14:00:58.245706+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
2018-10-04T14:00:58.245707+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
2018-10-04T14:00:58.245710+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2018-10-04T14:00:58.245711+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:145:in `block in perform'
2018-10-04T14:00:58.245712+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `tap'
2018-10-04T14:00:58.245713+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands/server/server_command.rb:142:in `perform'
2018-10-04T14:00:58.245714+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
2018-10-04T14:00:58.245715+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
2018-10-04T14:00:58.245716+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
2018-10-04T14:00:58.245718+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
2018-10-04T14:00:58.245721+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
2018-10-04T14:00:58.245723+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
2018-10-04T14:00:58.245724+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
2018-10-04T14:00:58.245725+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
2018-10-04T14:00:58.245727+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
2018-10-04T14:00:58.245730+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
2018-10-04T14:00:58.245734+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
2018-10-04T14:00:58.245737+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
2018-10-04T14:00:58.245738+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
2018-10-04T14:00:58.245744+00:00 app[web.1]: from bin/rails:9:in `<main>'
2018-10-04T14:00:58.245741+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
2018-10-04T14:01:03.346945+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=inventory2-180924.herokuapp.com request_id=a6550ebc-ed79-48a2-81fb-2404cb71efa0 fwd="87.151.1.121" dyno= connect= service= status=503 bytes= protocol=https
I've not yet been able to pinpoint what is going on here. Will try to narrow it down further when I get a chance.
But this gives the right results:
[5] pry(#<IRR>)> both
=> [T(-627752.0,2017-02-23), T(-75167.0,2017-11-07), T(6.9,2020-03-01)]
[6] pry(#<IRR>)> both.xirr
=> -0.984602e0
This does not:
=> [T(-627752.0,2017-02-23), T(-75167.0,2017-11-07), T(6.8,2020-03-01)]
[3] pry(#<IRR>)> both.xirr
=> 0.0
The expected value would be converging towards -1 as the positive amount in the last transaction converges on 0. As far as I can tell, somewhere between 6.9 and 6.8 is the last point where it gets the correct results.
Hey there!
Could you explain why the following code enter in infinite loop?
cf = Xirr::Cashflow.new
cf << Xirr::Transaction.new(-1, date: '2019-09-25'.to_date)
cf << Xirr::Transaction.new(-1, date: '2020-02-26'.to_date)
cf << Xirr::Transaction.new(-1, date: '2020-02-28'.to_date)
cf << Xirr::Transaction.new(1 , date: '2020-03-23'.to_date)
cf.xirr
Curiously, if I remove any transaction, it will work.
I noticed the issue occours in Newton#nsolve of ruby library.
Thanks!
Could a new version 0.7.0 be released?
There's an important change #19 which allows to use different rails versions.
Tubedude, maybe you could try the RubyInline gem and do the more numerically intensive loops in C.
Specially, this could really speed the numeric methods (bisection and newton) used in XIRR.
config/initalizer/xirr.rb
Xirr.configure do |config|
config.period = 5000
end
Entering the rails console and checking Xirr::PERIOD
its still the default value 365
.
rails 5.2
ruby 2.5.x
cf = Cashflow.new
cf << Transaction.new(-10000, date: '2014-04-015'.to_date)
cf << Transaction.new(-305.6, date: '2014-05-015'.to_date)
cf << Transaction.new( 500, date: '2014-10-19'.to_date)
cf.xirr
-0.1001195E1 [BigDecimal]
However, the result in google spreadsheet is -0.996814607
Working on a Digital Ocean droplet with Ubuntu 14.04 with Unicorn and Nginx, we encountered this error in production:
Define INLINEDIR or HOME in your environment and try again
Came up in the Unicorn log. It's an existing deployment and the error came up with the xirr
gem and then went away when we commented it out. Any thoughts on the workaround? Works fine in development on Mac OS but failed in production. Googling around for the error didn't yield much in the way of solutions. Found this on Stack http://stackoverflow.com/questions/6051399/rake-task-says-define-inlinedir-or-home-in-your-environment-and-try-again-how but wanted to see what you thought before just adding env variables without understanding what's causing the problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.