Returns the total amount received from a financial security at maturity <span align="right" style="background-color:99FF99"><strong>Excel: ACCRINTM</strong></span>

You're viewing an older version of this page (#299). View the current version.

View versions (2)

Interface

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

using namespace Finance::Banking;

Returns the accrued interest for a security that pays interest at maturity.

The function is based on the following equation:

Accrued = par*rate*\frac{A}{D}
(1)

Where

  • par is the current 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:
\copydoc YearBasis

\warning 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 \ref 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.

\bug See \ref 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:
\code
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
\endcode

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.

\par Reference
Microsoft Excel Help File

\Example
\code   
#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;
}
\endcode
Output:
\code
20.5479
\endcode

\param issue is the issue date when 
the security is issued to the buyer in Julian date form
\param maturity is security's maturity date, expressed as a serial
Julian date number
\param rate is the coupon rate of the security
\param par is the value of the security (defaults to1,000 if omitted)

Parameters

basis
is the day count basis, where
Blank

yb_USA = US (NASD) 30/360, yb_Act = Actual/actual yb_Act360 = Actual/360 yb_Act365 = Actual/365 yb_EU = European 30/360

Parameters

WorkLikeExcel
emulates Excel's "wrong" calculation
Blank

of Actual/actual; see documentation for details....

GPL Licence — free for non commercial use. See Licence details.