Skip to content

Instantly share code, notes, and snippets.

Ismael Ghalimi ghalimi

Block or report user

Report or block ghalimi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ghalimi
ghalimi / XIRR.js
Created Jan 30, 2013
XIRR Function
View XIRR.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / IRR.js
Created Jan 22, 2013
IRR Function
View IRR.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / NORMDIST.js
Last active Sep 25, 2019
NORMDIST Function
View NORMDIST.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function NORMDIST(x, mean, sd, cumulative) {
// Check parameters
if (isNaN(x) || isNaN(mean) || isNaN(sd)) return '#VALUE!';
if (sd <= 0) return '#NUM!';
// Return normal distribution computed by jStat [http://jstat.org]
return (cumulative) ? jStat.normal.cdf(x, mean, sd) : jStat.normal.pdf(x, mean, sd);
}
@ghalimi
ghalimi / PV.js
Created Jan 25, 2013
PV Function
View PV.js
// 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);
@ghalimi
ghalimi / NPER.js
Created Jan 23, 2013
NPER Function
View NPER.js
// 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)
@ghalimi
ghalimi / IPMT.js
Created Jan 22, 2013
IPMT Function
View IPMT.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@ghalimi
ghalimi / XNPV.js
Created Jan 30, 2013
XNPV Function
View XNPV.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function XNPV(rate, values, dates) {
var result = 0;
for (var i = 0; i < values.length; i++) {
result += values[i] / Math.pow(1 + rate, moment(dates[i]).diff(moment(dates[0]), 'days') / 365);
}
return result;
}
View NOMINAL.js
// 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
@ghalimi
ghalimi / NPV.js
Last active Mar 31, 2017
NPV Function
View NPV.js
// 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
@ghalimi
ghalimi / CUMIPMT.js
Last active Dec 21, 2016
CUMIPMT Function
View CUMIPMT.js
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
You can’t perform that action at this time.