hwtimespec
Specify time structure for Hull-White interest-rate tree
Description
sets the number of levels and node times for a TimeSpec
= hwtimespec(ValuationDate
,Maturity
)hwtree
and determines the mapping between dates and time for rate
quoting.
adds the optional argument TimeSpec
= hwtimespec(___,Compounding
)Compounding
.
Examples
Set the Number of Levels and Node Times for a Hull-White Tree
This example shows how to specify a four-period tree with annual nodes and use annual compounding to report rates.
ValuationDate = datetime(2004,1,1); Maturity = [datetime(2004,12,31) ; datetime(2005,12,31) ; datetime(2006,12,31) ; datetime(2007,12,31)]; Compounding = 1; TimeSpec = hwtimespec(ValuationDate, Maturity, Compounding)
TimeSpec = struct with fields:
FinObj: 'HWTimeSpec'
ValuationDate: 731947
Maturity: [4x1 double]
Compounding: 1
Basis: 0
EndMonthRule: 1
Input Arguments
ValuationDate
— Pricing date and first observation in the tree
datetime scalar | string scalar | date character vector
Pricing date and first observation in the tree, specified as a scalar datetime, string, or data character vector.
To support existing code, hwtimespec
also
accepts serial date numbers as inputs, but they are not recommended.
Maturity
— Dates marking the cash flow dates of the tree
datetime array | string array | date character vector
Dates marking the cash flow dates of the tree, specified as
NLEVELS
-by-1
vector using a datetime array,
string array, or date character vectors. Cash flows with these maturities fall on tree
nodes. Maturity
should be in increasing order.
To support existing code, hwtimespec
also
accepts serial date numbers as inputs, but they are not recommended.
Compounding
— Rate at which the input zero rates were compounded when annualized
1
(default) | integer with value of 1
, 2
,
3
, 4
, 6
,
12
, 365
, or -1
(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)
, whereF
is the compounding frequency,Z
is the zero rate, andT
is the time in periodic units; for example,T = F
is one year.If
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.If
Compounding
=−1
:Disc = exp(-T*Z)
, whereT
is time in years.
Data Types: double
Output Arguments
TimeSpec
— Specification for the time layout for hwtree
structure
Version History
Introduced before R2006aR2022b: Serial date numbers not recommended
Although hwtimespec
supports serial date numbers,
datetime
values are recommended instead. The
datetime
data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime
values, use the datetime
function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)