time2date
Dates from time and frequency
Description
computes Dates
= time2date(___,Compounding
,Basis
,EndMonthRule
)Dates
corresponding
to compounded rate quotes between Settle
and TFactors
using
optional input arguments for Compounding
, Basis
,
and EndMonthRule
. time2date
is
the inverse of date2time
.
Examples
Calculate Dates Using time2date
Show that date2time
and time2date
are the inverse of each other. First compute the time factors using date2time
.
Settle = '1-Sep-2002'; Dates = datenum(['31-Aug-2005'; '28-Feb-2006'; '15-Jun-2006'; '31-Dec-2006']); Compounding = 2; Basis = 0; EndMonthRule = 1; TFactors = date2time(Settle, Dates, Compounding, Basis,... EndMonthRule)
TFactors = 4×1
5.9945
6.9945
7.5738
8.6576
Now use the calculated TFactors
in time2date
and compare the calculated dates with the original set.
Dates_calc = time2date(Settle, TFactors, Compounding, Basis,... EndMonthRule)
Dates_calc = 4×1
732555
732736
732843
733042
datestr(Dates_calc)
ans = 4x11 char array
'31-Aug-2005'
'28-Feb-2006'
'15-Jun-2006'
'31-Dec-2006'
Show time2date
support for datetime
input for Settle
.
Settle = '1-Sep-2002'; Dates = datenum(['31-Aug-2005'; '28-Feb-2006'; '15-Jun-2006'; '31-Dec-2006']); Compounding = 2; Basis = 0; EndMonthRule = 1; TFactors = date2time(Settle, Dates, Compounding, Basis,... EndMonthRule); Dates_calc = time2date(datetime(Settle,'Locale','en_US'), TFactors,... Compounding, Basis, EndMonthRule)
Dates_calc = 4x1 datetime
31-Aug-2005
28-Feb-2006
15-Jun-2006
31-Dec-2006
Input Arguments
Settle
— Settlement date
serial date number | date character vector | datetime object
Settlement date, specified as a serial date number, date character vector, or datetime array.
Data Types: double
| char
| datetime
TFactors
— Time factors
vector
Time factors, corresponding to the compounding value, specified
as a vector. TFactors
must be equal to or greater
than zero.
Data Types: double
Compounding
— Rate at which input zero rates are compounded when annualized
2
(Semiannual compounding) (default) | scalar with numeric values of 0
, 1
, 2
, 3
, 4
, 5
, 6
, 12
, 365
, –1
Rate at which input zero rates are compounded when annualized,
specified as a scalar with numeric values of: 0
, 1
, 2
, 3
, 4
, 5
, 6
, 12
, 365
,
or –1
. Allowed values are defined as:
0
— Simple interest (no compounding)1
— Annual compounding2
— Semiannual compounding (default)3
— Compounding three times per year4
— Quarterly compounding6
— Bimonthly compounding12
— Monthly compounding365
— Daily compounding-1
— Continuous compounding
The optional Compounding
argument determines
the formula for the discount factors (Disc
):
Compounding
=1
,2
,3
,4
,6
,12
Disc = (1 + Z/F)^(-T)
, whereF
is the compounding frequency,Z
is the zero rate, andT
is the time in periodic units, for example,T = F
is one year.
Compounding
=365
Disc = (1 + Z/F)^(-T)
, whereF
is the number of days in the basis year andT
is a number of days elapsed computed by basis.
Compounding
=-1
Disc = exp(-T*Z)
, whereT
is time in years.
Basis
— Day-count basis
0
(actual/actual) (default) | numeric with value 0
through 13
| vector of numerics with values 0
through 13
Day-count basis, specified as an integer with a value of 0
through 13
or
a N
-by-1
vector of integers
with values 0
through 13
.
0 = actual/actual (default)
1 = 30/360 (SIA)
2 = actual/360
3 = actual/365
4 = 30/360 (BMA)
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: single
| double
EndMonthRule
— End-of-month rule flag for month having 30 or fewer days
1
(in effect) (default) | nonnegative integer [0,1]
End-of-month rule flag for month having 30 or fewer days, specified
as scalar nonnegative integer [0
, 1
]
or a using a N
-by-1
vector of
values. This rule applies only when Maturity
is
an end-of-month date for a month having 30 or fewer days.
0
= Ignore rule, meaning that a payment date is always the same numerical day of the month.1
= Set rule on, meaning that a payment date is always the last actual day of the month.
Data Types: logical
Output Arguments
Dates
— Dates corresponding to compounded rate quotes between Settle
and TFactors
serial date number | datetime array
Version History
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)