macaulay-duration
v1.0.2
Published
A library to calculate the Macaulay Duration and Modified Duration in Node.js
Downloads
8
Maintainers
Readme
Macaulay Duration JS
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
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
Copyright (c) 2016 Supasate Choochaisri
Licensed under the Apache License.