| Contents |
#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 |
| doubleaccruedInterest( | int | issue | |
| int | maturity | ||
| double | rate | ||
| double | par = 1000.0 | ||
| YearBasis | basis = yb_USA | ||
| bool | WorkLikeExcel = false | ) |
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.448230If 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.
#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.5479the security is issued to the buyer in Julian date form
Julian date number
| Type | Value | Description |
| yb_US | 0 | US (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_Act | 1 | Uses the exact number of elapsed days between the two dates, as well as the exact length of the year. |
| yb_Act360 | 2 | Uses the exact number of elapsed days between two dates but assumes the year only have 360 days |
| yb_Act365 | 3 | Uses the exact number of elapsed days between two dates but assumes the year always has 365 days |
| yb_EU | 4 | European 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. |
| issue | is the issue date when |
| maturity | is security's maturity date, expressed as a serial |
| rate | is the coupon rate of the security |
| par | is the value of the security (defaults to 1,000 if omitted) |
| basis | is the day count basis, where: |
| WorkLikeExcel | emulates Excel's "wrong" calculation of Actual/actual; see documentation for details.... |