Skip to content

Instantly share code, notes, and snippets.

View ghalimi's full-sized avatar

Ismael Ghalimi ghalimi

View GitHub Profile
@ghalimi
ghalimi / terms.html
Last active December 15, 2015 03:58
STOIC Terms of Service
<p><strong>Last updated:</strong> March 19, 2013.</p>
<p>These Terms of Service ("Terms") govern your access to and use of STOIC ("STOIC", "we" or "our") websites, services, and applications (collectively the "Service"). Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. These Terms apply to all visitors, users and others who access or use the Service.</p>
<h3>Your Use of the Service</h3>
<p>By accessing or using the Service you agree to be bound by these Terms. If you are using the Services on behalf of an organization or entity ("Organization"), then you are agreeing to these Terms on behalf of that Organization and you represent and warrant that you have the authority to bind the Organization to these Terms. In that case, "you" and "your" refers to you and that Organization.</p>
<p>You may use the Service only if you can form a binding contract with STOIC, and only in compliance with these Terms and all applicable local, state, national, and internat
@ghalimi
ghalimi / TBILLYIELD.js
Created January 29, 2013 01:48
TBILLYIELD Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function TBILLYIELD(settlement, maturity, price) {
// Return error if either date is invalid
if (!moment(settlement).isValid() || !moment(maturity).isValid()) return '#VALUE!';
// Return error if price is lower than or equal to zero
if (price <= 0) return '#NUM!';
// Return error if settlement is greater than maturity
@ghalimi
ghalimi / TBILLEQ.js
Created January 29, 2013 00:22
TBILLEQ Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function TBILLEQ(settlement, maturity, discount) {
// Return error if either date is invalid
if (!moment(settlement).isValid() || !moment(maturity).isValid()) return '#VALUE!';
// Return error if discount is lower than or equal to zero
if (discount <= 0) return '#NUM!';
// Return error if settlement is greater than maturity
@ghalimi
ghalimi / SYD.js
Created January 27, 2013 18:51
SYD Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function SYD(cost, salvage, life, period) {
// Return error if any of the parameters is not a number
if (isNaN(cost) || isNaN(salvage) || isNaN(life) || isNaN(period)) return '#VALUE!';
// Return error if life equal to 0 (zero)
if (life === 0) return '#NUM!';
// Return error if period is lower than 1 or greater than life
@ghalimi
ghalimi / SLN.js
Created January 27, 2013 18:33
SLN Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function SLN(cost, salvage, life) {
// Return error if any of the parameters is not a number
if (isNaN(cost) || isNaN(salvage) || isNaN(life)) return '#VALUE!';
// Return error if life equal to 0 (zero)
if (life === 0) return '#NUM!';
// Return straight-line depreciation
@ghalimi
ghalimi / RRI.js
Created January 26, 2013 17:42
RRI Function
// 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
@ghalimi
ghalimi / PDURATION.js
Created January 24, 2013 15:39
PDURATION Function
// 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
@ghalimi
ghalimi / MIRR.js
Created January 22, 2013 23:29
MIRR Function
// 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++) {
@ghalimi
ghalimi / ISPMT.js
Created January 22, 2013 19:23
ISPMT Function
// 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);
}
@ghalimi
ghalimi / FVSCHEDULE.js
Last active December 11, 2015 10:58
FVSCHEDULE Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function FVSCHEDULE(principal, schedule) {
// Initialize future value
var future = principal;
// Apply all interests in schedule
for (var i = 0; i < schedule.length; i++) {
// Return error if schedule value is not a number
if (isNaN(schedule[i])) return '#VALUE!';