discountfactors
Description
Examples
Calculate Discount Factors for a ratecurve
Object
Create a ratecurve
object using ratecurve
.
Settle = datetime(2019,9,15); Type = 'zero'; ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]'; ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]'; ZeroDates = Settle + ZeroTimes; myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates,'Compounding',2,'Basis',5,'InterpMethod',"pchip",'ShortExtrapMethod',"linear",'LongExtrapMethod',"pchip")
myRC = ratecurve with properties: Type: "zero" Compounding: 2 Basis: 5 Dates: [10x1 datetime] Rates: [10x1 double] Settle: 15-Sep-2019 InterpMethod: "pchip" ShortExtrapMethod: "linear" LongExtrapMethod: "pchip"
Compute the discount factors using discountfactors
.
CurveSettle = datetime(2019,9,15); outRates = discountfactors(myRC,CurveSettle+30:30:CurveSettle+720)
outRates = 1×24
0.9996 0.9992 0.9988 0.9983 0.9979 0.9974 0.9970 0.9965 0.9961 0.9956 0.9951 0.9946 0.9941 0.9936 0.9931 0.9926 0.9921 0.9915 0.9910 0.9904 0.9899 0.9893 0.9887 0.9881
Input Arguments
obj
— ratecurve
object
ratecurve
object | parametercurve
object
ratecurve
object, specified using a previously created ratecurve
object.
In addition, you can use a parametercurve
object. Also, you
can create a parametercurve
object using
fitNelsonSiegel
, fitSvensson
, or fitSmithWilson
.
Data Types: object
inpDates
— Input dates
datetime array | string array | date character vector
Input dates, specified as a scalar or an
NPOINTS
-by-1
vector using a datetime array,
string array, or date character vectors.
To support existing code, discountfactors
also
accepts serial date numbers as inputs, but they are not recommended.
Output Arguments
outDF
— Discount factors
numeric
Discount factors, returned as a numeric.
Version History
Introduced in R2020aR2022b: Serial date numbers not recommended
Although discountfactors
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.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)