Coder Social home page Coder Social logo

finance.js's People

Contributors

alhassanebarry avatar creaoticx avatar ebradyjobory avatar editter avatar gpedro avatar igorsantos07 avatar mmcdermott avatar olamilekan000 avatar seanpat09 avatar sharddith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finance.js's Issues

Not an issue

Just wanted to say thank you for the work you have put towards this. It's working fantastic with version 4. I failed to reply to a previous issue I put forward. I can't find it to reply now, but everything is working great. Thanks again!

Incorrect formula for FV calculation

The FV formula asks for the number of "periods". However, the wording should be changed to "years".

For example, a year might have 12 periods which means that the cumulative interest is calculated once a month. As of right now, the calculator would assume 12 periods means 1 cumulative interest period each year for 12 years.

finance.IRR causes "Cannot convert undefined or null to object" error

The example:

finance.IRR(-500000, 200000, 300000, 200000);

Result:

    Uncaught TypeError: Cannot convert undefined or null to object
    at slice (<anonymous>)
    at Finance.IRR (finance.self-e3a7ba8fd778d256a438ea068bd511733e341d18b95ce0cda6e89071e7a0edb2.js?body=1:51)
    at <anonymous>:1:9

Here:

    Finance.prototype.IRR = function(cfs) {
    var depth = cfs.depth;
    var args = cfs.cashFlow;
    var numberOfTries = 1;
    // Cash flow values must contain at least one positive value and one negative value
    var positive, negative;
    Array.prototype.slice.call(args).forEach(function (value) { // <<<<< Right here
        if (value > 0) positive = true;
        if (value < 0) negative = true;
    })

image

new calcs

Hello are you currently open to adding new calculators? I am happy to open a pull request for one some I use sometimes including Inflation-adjusted returns.

Bower package

It'd be great if you could create a bower package for this so people don't have to manually copy it over into their browser projects.

NPV not working

I tried your example:

finance.NPV(10, -500000, 200000, 300000, 200000);

I get 80015.03

But when I try it in Excel: =NPV(0.1, -500000, 200000, 300000, 200000)

I get 72740.93

Am I missing something here?

I need to replicate the NPV functionality in Jscript but I can't do this when I am getting 2 different results.

Any help would be appreciated.

[XIRR] The return of the follow instruction is not a % is an amount

I execute with the version "financejs": "^4.1.0",

the follow instruction

console.log(finance.XIRR([-91000.00, 75000.00, -11500.00, -3500.00, 75000.00, -86720.00, -2500.00, -8000.00, 75000.00, -2500.00, -480.00, 75000.00, -1040.00],[ new Date(2018, 10, 29 ), new Date(2018, 10, 29 ), new Date(2018, 11, 12 ), new Date(2018, 11, 22 ), new Date(2018, 11, 22 ), new Date(2018, 11, 29 ), new Date(2018, 12, 3 ), new Date(2018, 12, 10 ), new Date(2018, 12, 10 ), new Date(2018, 12, 20 ), new Date(2018, 12, 22 ), new Date(2018, 12, 27 ), new Date(2019, 1, 10 )],0));

and gives me the follow amount as a result

83206612.79

The idea as I understan os this function is return e % not an amount .

Someone knows, what could be the problem?

Time-weighted Rate of Return?

Love this library! :)

Would it be possible to implement a Time-Weighted Rate of Return function? I'm working on a project that needs it. If I end up creating my own function, I'll just PR it here, but I'm sort of hoping that there's an existing function that can just be incorporated here.

IRR precision

Hello!

I'm seeing a discrepancy calculating IRR compared to Excel. It isn't huge, but when annualising it is enough for it to be a problem.

Consider the following code.

cashFlow = [-206136.99, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 8993.21, 18993.21];
// Calculate monthly IRR
IRR = finance.IRR( { depth: 1500, cashFlow: cashFlow } );
// Annualise IRR
IRR = (Math.pow(1 + IRR / 100, 12) - 1) * 100;

This returns 0.72% (exactly) which annually becomes 8.99% (8.990490026994502).
Compared to Excel which gives me 0.71414% monthly and 8.91% annually (0.0891443135).

I would appreciate any clues as to why this is happening. I find the exact 0.72 a bit suspicious, is it possible that some rounding is happening there?

Cheers!

XIRR incorrect values for very large datasets

XIRR value is being calculated incorrectly for transactions of order 40k-50k, the incorrectness increases when the number of transactions increase say 80k-90k

This I had checked with other xirr packages which were returning the same value as well as Excel, which confirmed the calculations. The value calculated by this package was incorrect

seekZero IRR bug

the seekZero function gets into an infinite loop for some inputs to the IRR function.
Have patched it to abort the calculation after a second

//seekZero seeks the zero point of the function fn(x), accurate to within x \pm 0.01. fn(x) must be decreasing with x.
function seekZero(fn) {
var x = 1;
var ind = new Date().getTime();
while (fn(x) > 0) {
x += 1;
if(new Date().getTime()-ind>1000)
throw("seekZero failed");
}
while (fn(x) < 0) {
x -= 0.01
if(new Date().getTime()-ind>1000)
throw("seekZero failed");
}
return x + 0.01;
}

Is there a need for a real object in this library?

It would be much more friendly if the library was just a pack of functions, just like lodash or many others.

Why do we need to instantiate an empty object so we use the functions?
That also blocks us to rename functions when importing (i.e. futureValue makes more sense than a FV acronym, for laymen looking at the code).

[IRR-Question] Excel can generate result and finance.js can't

Hi @essamjoubori nice effort to write this package!
Pretty awesome!

I'm a bit new to this world and I'm having some difficult to understand why excel can do IRR with some values and finance.js can't. I'm guessing it's because javascript itself can't deal with imaginary numbers.

finance.js

screen shot 2017-04-23 at 22 41 33

excel

screen shot 2017-04-23 at 22 41 13

Please let me know your thoughts on how to overcome that.
Thank you!

Website is outdated

Some functions are missing from the said .org, such as PMT. I spent some time writing that function into the library only to notice later it's already there, but not in the "official" docs.

Please update it :(

Suggestion: make it a simple GHPage based on the README. Much better than leaving both out of sync (and making a markdown file seem like a HTML thing)

PV not working the same as Excel

Gives totally different values compared to other PV calculations. Not sure if this is different version of PV but it doesn't seem correct.
For reference, I use this function which behaves the same as Excel's version:

PV(rate, numOfPayments, pmt) {
		return pmt / rate * (1 - Math.pow(1 + rate, -numOfPayments));
	}

New maintainer of this project

Hi,

I use this library very often and for my own DCF calculator.

It seems as though this package has been abandoned. Could I request to take it over @ebradyjobory

I'd like to refactor it to normal functions, add testing, add more functions etc.

Thanks

Finance.js IRR function problem.

Hi, Essam.
I am Jacky from Taiwan.

Few day ago, my friend has a project use Finance.js, IRR function.
But, function was not enough precision than Excel IRR function.
So, my friend ask for my help

I look your program, and find 2 issues.

  1. dynamic guess variable isn't exist, and decimal is not enough.
  2. recursive call will happen stack error.

First, i tell to my friend to modify your program at some const variable.
That will fix issues 1, but at same time it will happen issues 2.
Because i use more decimal and more precision guess, it mean time complexity will grow, in recursive call it also mean more stack.

So, i write a do-while version to calculate, but performance still limit by browser.
Then, i write a burst-guess to speed-up, when VPN too huge.
e.g : Math.log(VPN).

My code is over here.
https://github.com/eastmoon/Tutorial-JavaScript/blob/master/Issues-FinanceIRR/Index.html

Hope it would be helpful for you

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.