Coder Social home page Coder Social logo

ex-xirr's People

Contributors

goodhamgupta avatar hparamah avatar vasuadari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ex-xirr's Issues

Invalid result from big calculation

Running this calculation results in an invalid value 0.006097 (correct value is closer to 0.120581416 according to google spreadsheets).

d = [{2038, 2, 4}, {2037, 11, 2}, {2037, 8, 2}, {2037, 5, 3}, {2037, 2, 4}, {2036, 11, 2}, {2036, 8, 2}, {2036, 5, 3}, {2036, 2, 5}, {2035, 11, 2}, {2035, 8, 2}, {2035, 5, 3}, {2035, 2, 4}, {2034, 11, 2}, {2034, 8, 2}, {2034, 5, 3}, {2034, 2, 4}, {2033, 11, 2}, {2033, 8, 2}, {2033, 5, 3}, {2033, 2, 4}, {2032, 11, 2}, {2032, 8, 2}, {2032, 5, 3}, {2032, 2, 5}, {2031, 11, 2}, {2031, 8, 2}, {2031, 5, 3}, {2031, 2, 4}, {2030, 11, 2}, {2030, 8, 2}, {2030, 5, 3}, {2030, 2, 4}, {2029, 11, 2}, {2029, 8, 2}, {2029, 5, 3}, {2029, 2, 4}, {2028, 11, 2}, {2028, 8, 2}, {2028, 5, 3}, {2028, 2, 5}, {2027, 11, 2}, {2027, 8, 2}, {2027, 5, 3}, {2027, 2, 4}, {2026, 11, 2}, {2026, 8, 2}, {2026, 5, 3}, {2026, 2, 4}, {2025, 11, 2}, {2025, 8, 2}, {2025, 5, 3}, {2025, 2, 4}, {2024, 11, 2}, {2024, 8, 2}, {2024, 5, 3}, {2024, 2, 5}, {2023, 11, 2}, {2023, 8, 2}, {2023, 5, 3}, {2023, 2, 4}, {2022, 11, 2}, {2022, 8, 2}, {2022, 5, 3}, {2022, 2, 4}, {2021, 11, 2}, {2021, 8, 2}, {2021, 5, 3}, {2021, 2, 4}, {2020, 11, 2}, {2020, 8, 2}, {2020, 5, 3}, {2020, 2, 5}, {2019, 11, 2}, {2019, 8, 2}, {2019, 5, 3}, {2019, 2, 4}, {2018, 11, 2}, {2018, 8, 2}, {2018, 5, 31}]
v = [-305, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 188.0]
iex(91)> ExXirr.xirr(d, v)
{:ok, 0.006097}

Weirdly enough, if you just change the last -5 to -4.8 the calculation will return the expected value, like this.

d = [{2038, 2, 4}, {2037, 11, 2}, {2037, 8, 2}, {2037, 5, 3}, {2037, 2, 4}, {2036, 11, 2}, {2036, 8, 2}, {2036, 5, 3}, {2036, 2, 5}, {2035, 11, 2}, {2035, 8, 2}, {2035, 5, 3}, {2035, 2, 4}, {2034, 11, 2}, {2034, 8, 2}, {2034, 5, 3}, {2034, 2, 4}, {2033, 11, 2}, {2033, 8, 2}, {2033, 5, 3}, {2033, 2, 4}, {2032, 11, 2}, {2032, 8, 2}, {2032, 5, 3}, {2032, 2, 5}, {2031, 11, 2}, {2031, 8, 2}, {2031, 5, 3}, {2031, 2, 4}, {2030, 11, 2}, {2030, 8, 2}, {2030, 5, 3}, {2030, 2, 4}, {2029, 11, 2}, {2029, 8, 2}, {2029, 5, 3}, {2029, 2, 4}, {2028, 11, 2}, {2028, 8, 2}, {2028, 5, 3}, {2028, 2, 5}, {2027, 11, 2}, {2027, 8, 2}, {2027, 5, 3}, {2027, 2, 4}, {2026, 11, 2}, {2026, 8, 2}, {2026, 5, 3}, {2026, 2, 4}, {2025, 11, 2}, {2025, 8, 2}, {2025, 5, 3}, {2025, 2, 4}, {2024, 11, 2}, {2024, 8, 2}, {2024, 5, 3}, {2024, 2, 5}, {2023, 11, 2}, {2023, 8, 2}, {2023, 5, 3}, {2023, 2, 4}, {2022, 11, 2}, {2022, 8, 2}, {2022, 5, 3}, {2022, 2, 4}, {2021, 11, 2}, {2021, 8, 2}, {2021, 5, 3}, {2021, 2, 4}, {2020, 11, 2}, {2020, 8, 2}, {2020, 5, 3}, {2020, 2, 5}, {2019, 11, 2}, {2019, 8, 2}, {2019, 5, 3}, {2019, 2, 4}, {2018, 11, 2}, {2018, 8, 2}, {2018, 5, 31}]
v = [-305, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -4.8, 188.0]
iex(102)> ExXirr.xirr(d, v)
{:ok, 0.120448}

spawn_link overhead is slow

Describe the bug

Thanks for the library. We are currently using LegacyFinance.xirr() which matches our expectations for the results. It is quite a bit slower than the newer version, but the slowness is unnecessary. Removing pmap results in a dramatic speed up. As a test, I created a Finance based on LegacyFinance module that replaces pmap with Enum.map. This is the result using your benchmark:

##### With input date_values #####
Name                     ips        average  deviation         median         99th %
finance               3.93 K      254.18 μs     ±2.71%      252.99 μs      272.99 μs
ex xirr               3.25 K      307.28 μs    ±12.77%      299.99 μs      421.99 μs
legacy finance        0.44 K     2284.52 μs     ±6.76%     2273.99 μs     2761.35 μs

As you can see, there is an order of magnitude speedup simply by making this change.

I did some experimentation with Stream.map as well, but it turned out that Enum.map was the fastest.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.