Skip to content

Instantly share code, notes, and snippets.

View ghalimi's full-sized avatar

Ismael Ghalimi ghalimi

View GitHub Profile
@ghalimi
ghalimi / XIRR.js
Created January 30, 2013 01:11
XIRR Function
// 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 / PV.js
Created January 25, 2013 23:27
PV Function
// 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 / CUMIPMT.js
Last active August 23, 2023 23:15
CUMIPMT Function
// 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 January 22, 2013 01:45
IRR Function
// 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 / FV.js
Created January 21, 2013 22:43
FV Function
// 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 / PPMT.js
Created January 25, 2013 20:03
PPMT Function
// 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);
}
@ghalimi
ghalimi / PMT.js
Last active April 27, 2023 16:40
PMT Function
// 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 / IPMT.js
Created January 22, 2013 00:35
IPMT Function
// 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
# query -> SELECT * FROM table
{
"select_query" : {
"select_node" : {
"projection_list": [
{
"type": "star_expression"
}
],
"from_clause": [
@ghalimi
ghalimi / YEARFRAC.js
Last active December 16, 2022 20:58
YEARFRAC Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function YEARFRAC(start_date, end_date, basis) {
// Credits: David A. Wheeler [http://www.dwheeler.com/]
// Initialize parameters
var basis = (typeof basis === 'undefined') ? 0 : basis;
var sdate = moment(new Date(start_date));
var edate = moment(new Date(end_date));