Code Monkey home page Code Monkey logo

bond-calculator's Introduction

Bond calculator

npm version Build Status Coverage Status Greenkeeper badge

Yield and price calculations for bonds.

Gives the same results as Excel YIELD and PRICE functions.

The following day count conventions are supported:

  • 30U/360
  • ACTUAL/ACTUAL
  • ACTUAL/360
  • ACTUAL/365
  • 30E/360

More info about day count conventions can be found on Wikipedia.

Installation

npm install --save bond-calculator

Usage

const bondCalculator = require('bond-calculator');

const bond = bondCalculator({
  settlement: '2016-12-26',
  maturity: '2023-01-17',
  rate: 0.02625, // 2.625%
  redemption: 100,
  frequency: 2, // 1=Annual, 2=Semiannual, 4=Quarterly
  convention: '30U/360',
});

// Calculate yield for a given price
const yld = bond.yield(98); // 2.98817753210426%

// Calculate price for a given yield
const price = bond.price(0.025); // 100.69785390232649

bond-calculator's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar jogold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bond-calculator's Issues

An in-range update of date-fns is breaking the build 🚨

The dependency date-fns was updated from 1.29.0 to 1.30.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

date-fns is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Angualr 6 help!

I'm using the repo in angular 6 and i'm a novice. after i import the file i get errors with its dependencies when trying to use the app. is help possible?

capture

Quarterly Payments are returning null response

I am have a list of bonds and when the frequency is set to 4 for a couple of bonds the response is NaN. When used with Annual or Semi-Annual it works fine

{ 
maturity: 2025-01-15,
redemption: 100,
settlement: 2018-08-21,
frequency: 4,
rate: .0.07,
convention: '30U/360' 
}

yld = bond.yield(100);

capture
An Suggestions?

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.16.0 to 2.17.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 61 commits.

  • 0499050 bump to v2.17.0
  • f479635 [webpack] v0.11.1
  • 8a4226d Merge pull request #1320 from bradzacher/export-ts-namespaces
  • 988e12b fix(export): Support typescript namespaces
  • 70c3679 [docs] make rule names consistent
  • 6ab25ea [Tests] skip a TS test in eslint < 4
  • 405900e [Tests] fix tests from #1319
  • 2098797 [fix] export: false positives for typescript type + value export
  • 70a59fe [fix] Fix overwriting of dynamic import() CallExpression
  • e4850df [ExportMap] fix condition for checking if block comment
  • 918567d [fix] namespace: add check for null ExportMap
  • 2d21c4c Merge pull request #1297 from echenley/ech/fix-isBuiltIn-local-aliases
  • 0ff1c83 [dev deps] lock typescript to ~, since it doesn’t follow semver
  • 40bf40a [*] [deps] update resolve
  • 28dd614 Merge pull request #1304 from bradennapier/feature/typescript-export-type

There are 61 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Purpose of dPriceDYld

This is not an entirely new issue but I wanted to understand the logic behind the dPriceDYld calculation. The reason I'm asking is that its Newton root is computed alongside the usual bond price _price.

Thank you.

Error: Newton's method failed to converge after 100 iterations

Hi! I have bond with next params:

{ 
  maturity: 2031-08-15T00:00:00.000Z,
  redemption: 100,
  settlement: 2018-04-25T00:00:00.000Z,
  frequency: 2,
  rate: 0.09,
  convention: '30U/360' 
}

When i try to calculate yield with price 58.4, i get error "Newton's method failed to converge after 100 iterations"

But in EXCEL this bond works fine.

Help me please!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.