Duration(Settlement: DateTime;
Maturity: DateTime;
CouponRate: Double;
YieldP: Double;
Frequency: Integer;
Basis: Integer): Double;
Duration(Settlement: System.DateTime;
Maturity: System.DateTime;
CouponRate: double;
YieldP: double;
Frequency: integer;
Basis: integer): double;
| Parameters | Description | Constraints |
| Settlement | Securities settlement date. | Must be less than Maturity. |
| Maturity | Securities maturity date. | Must be greater than Settlement. |
| CouponRate | Securities price for $100 of face value. | Cannot be negative. |
| YieldP | Redemption price for $100 of face value. | Cannot be negative. |
| Frequency | The number of payments for coupons in a year: 1 - For annual payments. 2 - For semi-annual payments. 4 - For quarterly payments. |
Must take the values 1, 2 or 4. |
| Basis | The employed method of day calculation: 0 - American/360 days (NSAD method). 1 - Factual/factual. 2 - Factual/360days. 3 - Factual/365 days. 4 - European 30/360 days. |
Must be in the [0,4] interval. |
The Duration method returns Macaulay duration for supposed face value of $100.
The duration is determined as a weighted mean of present value of cash flows and is used as a measure of reaction of bond prices to change in yield.
The agreement date is the date of selling a coupon, for example, a bond, to the buyer. The payment date is the coupon expiry date. For example, a bond with duration of 30 years was issued on Jan 1 2008 and was acquired by a buyer in 6 months after the issue date. The issue date is Jan 1 2008, the settlement date - July 1 2008, and the maturity date is Jan 1 2038, that is 30 years after the issue date.
To execute the example, add a link to the MathFin system assembly.
Sub UserProc;
Var
r: Double;
Begin
r := Finance.Duration(DateTime.ComposeDay(2008, 01, 01), DateTime.ComposeDay(2008, 06, 01), 0.28, 0.82, 4, 3);
Debug.WriteLine(r);
End Sub UserProc;
After executing the example the console window displays the Macaulay duration equal to 0.3968006367813.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.MathFin;
…
Public Shared Sub Main(Params: StartParams);
Var
r: double;
Finance: FinanceClass = New FinanceClass();
DateTime1, DateTime2: System.DateTime;
Begin
DateTime1 := New DateTime(2008,01,01);
DateTime2 := New DateTime(2008,06,01);
r := Finance.Duration(DateTime1, DateTime2, 0.28, 0.82, 4, 3);
System.Diagnostics.Debug.WriteLine(r);
End Sub;
See also: