Main Content

date2time

Time and frequency from dates

Description

example

[Times,F] = date2time(Settle,Maturity) computes time factors appropriate to compounded rate quotes beyond the settlement date.

example

[Times,F] = date2time(___,Compounding,Basis,EndMonthRule) add additional optional arguments.

Examples

collapse all

This example shows how to compute time and frequency from dates.

Settle = '1-Sep-2002';
Maturity = datenum(['31-Aug-2005'; '28-Feb-2006'; '15-Jun-2006'; 
                 '31-Dec-2006']);
Compounding = 2;
Basis = 0;
EndMonthRule = 1;
Times = date2time(Settle, Maturity, Compounding, Basis, EndMonthRule)
Times = 4×1

    5.9945
    6.9945
    7.5738
    8.6576

Input Arguments

collapse all

Settlement date, specified as a scalar serial date number or date character vector.

Data Types: char | double

Maturity dates, specified as a scalar numeric or an N-by-1 vector of dates.

Data Types: double

(Optional) Rate at which the input zero rates were compounded when annualized, specified as a scalar integer value.

  • If Compounding = 1, 2, 3, 4, 6, 12:

    Disc = (1 + Z/F)^(-T), where F is the compounding frequency, Z is the zero rate, and T is the time in periodic units; for example, T = F is one year.

  • If Compounding = 365:

    Disc = (1 + Z/F)^(-T), where F is the number of days in the basis year and T is a number of days elapsed computed by basis.

  • If Compounding = −1:

    Disc = exp(-T*Z), where T is time in years.

Data Types: double

(Optional) Day-count basis, specified as a scalar or an N-by-1 vector using the following values:

  • 0 = actual/actual

  • 1 = 30/360 (SIA)

  • 2 = actual/360

  • 3 = actual/365

  • 4 = 30/360 (PSA)

  • 5 = 30/360 (ISDA)

  • 6 = 30/360 (European)

  • 7 = actual/365 (Japanese)

  • 8 = actual/actual (ICMA)

  • 9 = actual/360 (ICMA)

  • 10 = actual/365 (ICMA)

  • 11 = 30/360E (ICMA)

  • 12 = actual/365 (ISDA)

  • 13 = BUS/252

For more information, see Basis.

Data Types: double

(Optional) End-of-month rule flag, specified as a scalar or an N-by-1 vector of end-of-month rules.

  • 0 = Ignore rule, meaning that a bond coupon payment date is always the same numerical day of the month.

  • 1 = Set rule on, meaning that a bond coupon payment date is always the last actual day of the month.

Data Types: logical

Output Arguments

collapse all

Time factors appropriate to compounded rate quotes between Settle and Maturity dates, returned as an N-by-1 vector.

Frequency, returned as a scalar of related compounding frequencies.

Note

To obtain accurate results from this function, the Basis and Maturity arguments must be consistent. If the Maturity argument contains months that have 31 days, Basis must be one of the values that allow months to contain more than 30 days; for example, Basis = 0, 3, or 7.

date2time is the inverse of time2date.

Introduced before R2006a