I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL

accrued Interest

viewed 3532 times and licensed 60 times
Finance functions
Controller: CodeCogs






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:

  • par is the par value of the security (if not specified, 1,000 is assumed),
  • rate is the security's annual coupon rate
  • A is the days from the issue date to maturity, and
  • D is the number of days in a year, depending on the year basis.


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.


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.

Example 1

#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;

the security is issued to the buyer in Julian date form

Julian date number

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.


issueis the issue date when
maturityis security's maturity date, expressed as a serial
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:
WorkLikeExcelemulates Excel's "wrong" calculation of Actual/actual; see documentation for details....


Alwyn Tan, March 2005
Source Code

Source code is available when you agree to a GP Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.