@travishorn/financejs
    Preparing search index...

    Function calculateDatedInternalRateOfReturn

    • Calculates the internal rate of return for a schedule of cash flows that is not necessarily periodic. To calculate the internal rate of return for a series of periodic cash flows, use the calculateInternalRateOfReturn() function.

      Remarks:

      • cashFlows and dates must be arrays of equal length, with at least 2 entries.
      • cashFlows must contain at least one positive and one negative cash flow.
      • All values in dates must be valid Date objects, and no date may precede the first date in the array.
      • In most cases you do not need to provide guess for the calculation. If omitted, guess defaults to 0.1 (10 percent).
      • guess must be greater than -1.
      • calculateDatedInternalRateOfReturn() is closely related to calculateDatedNetPresentValue(), the net present value function. The rate of return calculated by calculateDatedInternalRateOfReturn() is the interest rate corresponding to XNPV = 0.
      • Uses an iterative technique for calculating XIRR. Using a changing rate (starting with guess), this function cycles through the calculation until the result is accurate within a small absolute threshold. If this function can't find a result that works after 200 tries, a RangeError is thrown.

      Parameters

      • options: DatedInternalRateOfReturnOptions

        The dated internal rate of return calculation options.

      Returns number

      The internal rate of return.

      When inputs are invalid or the algorithm cannot converge.

      const cashFlows = [-10000, 2750, 4250, 3250, 2750];
      const dates = [new Date("2008-01-01"), new Date("2008-03-01"), new Date("2008-10-30"), new Date("2009-02-15"), new Date("2009-04-01")];
      calculateDatedInternalRateOfReturn({ cashFlows, dates, guess: 0.1 }); // 0.37336254