financebanking

accrued Interest

Available under GPL (Free) and Commercial licence
get a GPL licence
COST (GBP)
this unit 0.90
sub units 6.95
add a commercial licence to your cart
0
viewed 3362 times and licensed 28 times
www.codecogs.com/d-ox/finance/banking/accruedinterest.php
Other modules that are used by this module. We add these to the cart for you whenever you add this module, unless you already own enough licences for them. Click for details
Controller: CodeCogs    Contact Controller

Interface

#include <codecogs/finance/banking/accruedinterest.h>

using namespace Finance::Banking;

double accruedInterest (int issue, int maturity, double rate, double par=1000.0, YearBasis basis=yb_USA, bool WorkLikeExcel=false)
Returns the total amount received from a financial security at maturity Excel: ACCRINTM

Function Documentation

Accrued Interest Calculator

  

Add calculator to your site or email
 
doubleaccruedInterestintissue
intmaturity
doublerate
doublepar = 1000.0
YearBasisbasis = yb_USA
boolWorkLikeExcel = false )
Returns the accrued interest for a security that pays interest at maturity.

The function is based on the following equation:
(1)
\displaystyle Accrued = par*rate*frac{A}{D}

Where

Warnings:
This function differs from its Excel cousin in that it performs a more accurate calculation of securities using the Actual/Actual day count basis, when WorkLikeExcel=false. Specifically, it accurately determines if the settlement date falls in a leap year (Excel thinks that every 4th year is a leap year, see isleapyear), and we also check if the 'leap day'; on the 29th Feb falls between the maturity and settlement dates. Only when these two conditions are satisfied is the year assumed to have 366 days. In insances when the settlement to maturity span several years, and one or more of these years is a leap years, then the average of the year lengths is used.

Bugs:
See totalreceived for details of an ongoing very minor bug to the calculations using yb_Act when replicating Excel's behaviour. The following example illustrates the difference with this function:
accruedInterest(date(1995,5,2), date(1996,3,5), 738, 0.057, yb_Act, true) -> 35.39980328
ACCRINTM('2/5/1995', '5/3/1996', 738 0.057, 1) -> 35.448230

If rate or par is less than or equal to 0, or the issue date is greater than the maturity date, the function will return a value of -1.

Reference
Microsoft Excel Help File
Example:
#include <iostream>
#include <codecogs/finance/banking/accruedinterest.h>
 
int main()
{ 
  std::cout << Finance::Banking::accruedInterest(Units::Date::date(1998,4,1), Units::Date::date(1998,6,15), 0.1, 1000,
Finance::Banking::yb_Act365);
  return 0;
}
Output:
20.5479
Parameters:
issueis the issue date when the security is issued to the buyer in Julian date form
maturityis security's maturity date, expressed as a serial Julian date number
rateis the coupon rate of the security
paris the value of the security (defaults to $1,000 if omitted)
basisis the day count basis, where:
TypeValueDescription
yb_US0US (NASD) 30/360 - As with the European 30/360 (yb_EU, with the additional provision that if the end date occurs on the 31st of a month it is moved to the 1st of the next month if the start date is earlier than the 30th.
yb_Act1Uses the exact number of elapsed days between the two dates, as well as the exact length of the year.
yb_Act3602Uses the exact number of elapsed days between two dates but assumes the year only have 360 days
yb_Act3653Uses the exact number of elapsed days between two dates but assumes the year always has 365 days
yb_EU4European 30/360 - Each month is assumed to have 30 days, such that the year has only 360 days. Start and end dates that occur on the 31st of a month become equal to the 30th of the same month.
WorkLikeExcelemulates Excel's "wrong" calculation of Actual/actual; see documentation for details....
Authors:
Alwyn Tan, March 2005
Source Code:
Register

- To get code register with CodeCogs. Already a Member, then Login.


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2008-05-09 08:17:14

Page Comments

  You must login to leave a messge


Valid CSS!   Valid XHTML 1.0 Transitional