1.0.2 • Published 8 years ago

macaulay-duration v1.0.2

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
8 years ago

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.