This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function RRI(periods, present, future) { | |
// Return error if any of the parameters is not a number | |
if (isNaN(periods) || isNaN(present) || isNaN(future)) return '#VALUE!'; | |
// Return error if periods or present is equal to 0 (zero) | |
if (periods === 0 || present === 0) return '#NUM!'; | |
// Return equivalent interest rate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function RATE(periods, payment, present, future, type, guess) { | |
// Credits: rabugento | |
// Initialize guess | |
var guess = (typeof guess === 'undefined') ? 0.01 : guess; | |
// Initialize future | |
var future = (typeof future === 'undefined') ? 0 : future; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function PV(rate, periods, payment, future, type) { | |
// Initialize type | |
var type = (typeof type === 'undefined') ? 0 : type; | |
// Evaluate rate and periods (TODO: replace with secure expression evaluator) | |
rate = eval(rate); | |
periods = eval(periods); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function PPMT(rate, period, periods, present, future, type) { | |
return PMT(rate, periods, present, future, type) - IPMT(rate, period, periods, present, future, type); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function PDURATION(rate, present, future) { | |
// Return error if any of the parameters is not a number | |
if (isNaN(rate) || isNaN(present) || isNaN(future)) return '#VALUE!'; | |
// Return error if rate <=0 | |
if (rate <= 0) return '#NUM!'; | |
// Return number of periods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function NPER(rate, payment, present, future, type) { | |
// Initialize type | |
var type = (typeof type === 'undefined') ? 0 : type; | |
// Initialize future value | |
var future = (typeof future === 'undefined') ? 0 : future; | |
// Evaluate rate and periods (TODO: replace with secure expression evaluator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function NOMINAL(rate, periods) { | |
// Return error if any of the parameters is not a number | |
if (isNaN(rate) || isNaN(periods)) return '#VALUE!'; | |
// Return error if rate <=0 or periods < 1 | |
if (rate <=0 || periods < 1) return '#NUM!'; | |
// Truncate periods if it is not an integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function MIRR(values, finance_rate, reinvest_rate) { | |
// Initialize number of values | |
var n = values.length; | |
// Lookup payments (negative values) and incomes (positive values) | |
var payments = []; | |
var incomes = []; | |
for (var i = 0; i < n; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function NPV() { | |
// Cast arguments to array | |
var args = []; | |
for (i = 0; i < arguments.length; i++) { | |
args = args.concat(arguments[i]); | |
} | |
// Lookup rate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Sutoiku, Inc. (MIT License) | |
function ISPMT(rate, period, periods, value) { | |
// Evaluate rate and periods (TODO: replace with secure expression evaluator) | |
rate = eval(rate); | |
periods = eval(periods); | |
// Return interest | |
return value * rate * (period / periods - 1); | |
} |