macaulay-duration

1.0.2 • Public • Published

Macaulay Duration JS

Build Status

A library to calculate the Macaulay Duration and Modified Duration in Node.js

Installation

npm install --save macaulay-duration

Usage

Macaulay Duration

ES5

var duration = require('macaulay-duration').duration;
 
var faceValue = 10000; // 10000 dollars
var couponRate = 0.05; // 5%
var maturity = 5; // 5 years
var years = duration(faceValue, couponRate, maturity);
 
console.log('The Macaulay Duration is ' + years + ' years');
// The Macaulay Duration is 4.546 years

ES6

import { duration } from 'macaulay-duration'
 
const faceValue = 10000 // 10000 dollars
const couponRate = 0.05 // 5%
const maturity = 5 // 5 years
const years = duration(faceValue, couponRate, maturity)
 
console.log('The Macaulay Duration is ' + years + ' years')
// The Macaulay Duration is 4.546 years

Modified Duration

ES5

var modifiedDuration = require('macaulay-duration').modifiedDuration;
 
var faceValue = 10000; // 10000 dollars
var couponRate = 0.05; // 5%
var maturity = 5; // 5 years
var years = modifiedDuration(faceValue, couponRate, maturity);
 
console.log('The Modified Duration is ' + years + ' years');
// The Modified Duration is 4.546 years

ES6

import { modifiedDuration } from 'macaulay-duration'
 
const faceValue = 10000 // 10000 dollars
const couponRate = 0.05 // 5%
const maturity = 5 // 5 years
const years = modifiedDuration(faceValue, couponRate, maturity)
 
console.log('The Modified Duration is ' + years + ' years')
// The Modified Duration is 4.546 years

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

Copyright (c) 2016 Supasate Choochaisri

Licensed under the Apache License.

Package Sidebar

Install

npm i macaulay-duration

Weekly Downloads

1

Version

1.0.2

License

Apache-2.0

Last publish

Collaborators

  • supasate