calcIRR(arrCashFlow)
Last updated October 10, 2011
Version: 1 | Requires: ColdFusion MX | Library: FinancialLib
Description:
Calculates Internal Rate of Return (IRR) similar to excel IRR function.
Return Values:
Returns a numeric value.
Example:
cFlow = arrayNew(1);
cFlow[1] = -4000;
cFlow[2] = 1200;
cFlow[3] = 1410;
cFlow[4] = 1875;
cFlow[5] = 1050;
myIRR = calcIRR(cFlow);
</cfscript>
<cfdump var="#cFlow#">
<cfoutput>irr = #myIRR#</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| arrCashFlow | Array of cashflow. | Yes |
Full UDF Source:
<!---
Calculate IRR.
@param arrCashFlow Array of cashflow. (Required)
@return Returns a numeric value.
@author FALCONSEYE (falconseye@live.com)
@version 1, October 10, 2011
--->
<cffunction name="calcIRR" output="false">
<cfargument name="arrCashFlow" type="Array" required="yes" hint="array of cashflow">
<cfscript>
var guess = 0.1;
var inc = 0.00001;
do {
guess += inc;
npv = 0; //net present value
for (var i=1; i<=arrayLen(arguments.arrCashFlow); i++) {
npv += arguments.arrCashFlow[i] / ((1 + guess) ^ i);
}
} while ( npv > 0 );
guess = guess * 100;
</cfscript>
<cfreturn guess>
</cffunction>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)