fitfunction
Custom fit interest-rate curve object to bond market data
Syntax
描述
fits a bond to a custom fitting function.CurveObj
= fitFunction(类型
,Settle
,FunctionHandle
,乐器s
,irfitoptionsobj
)
例子
Fit a Bond Using Custom Fitting Function
This example shows how to usefitfunction
自定义适合债券。
settle = repmat(datenum(datenum)('30-Apr-2008'),[6 1]);成熟= [datenum('07-Mar-2009'); datenum('07 -MAR-2011');...datenum('07-Mar-2013'); datenum('07-Sep-2016');...datenum('07-Mar-2025'); datenum('07 -MAR-2036')]; CleanPrice = [100.1;100.1;100.8;96.6;103.3;96.3]; CouponRate = [0.0400;0.0425;0.0450;0.0400;0.0500;0.0425]; Instruments = [Settle Maturity CleanPrice CouponRate]; CurveSettle = datenum('30-Apr-2008');OptOptions = optimoptions('lsqnonlin','展示','iter');functionHandle = @(t,theta)polyval(theta,t);custommodel = irfunctioncurve.fitfunction('零',曲线,...功能手,仪器,...IRFitOptions([.05 .05 .05],'FitType','price',...'OptOptions',OptOptions))
一阶迭代函数计算f(x)步骤最优性0 4 38036.7 4.92E+04 1 8 38036.7 10 4.92E+04 2 12 38036.7 2.5 4.92E+04 3 16 38036.7 0.625 4.925 4.92E 4.92E4.92e+04 5 24 30741.5 0.0390625 1.72e+05 6 28 30741.5 0.078125 1.72e+05 7 32 30741.5 0.0195312 1.72e+05 8 36 28713.6 0.00488281 2.33e+05 9 40 20323.3 0.00976562 9.47e+05 10 44 20323.3 0.0195312 9.47e+05 11 48 20323.3 0.00488281 9.47e+05 12 52 20323.3 0.0012207 9.47e+05 13 56 19698.8 0.000305176 1.08e+06 14 60 17493 0.000610352 7e+06 15 64 17493 0.0012207 7e+06 16 68 17493 0.000305176 7e+06 17 72 15455.17.62939E-05 2.25E+07 18 76 15455.1 0.000177499 2.25E+07 19 80 13317.1 3.8147E-05 3.18e-07+07 20 84 1284 12865.3 7.62939E-07.62939E-05 7.83E 7.83E 7.83E 7.83E 7.83E 22 22 22 22 2222988.6293EEM92 11747.6 0.000152588 1.45e+05 23 96 11720.9 0.000305176 2.33e+05 24 100 11667.2 0.000610352 1.48e+05 25 104 11558.6 0.0012207 3.55e+05 26 108 11335.5 0.00244141 1.57e+05 27 112 10863.8 0.00488281 6.36e+05 28 116 9797.140.00976562 2.53E+05 29 1206882.83 0.0195312 9.18e+05 30 124 6882.83 0.0373992 9.18e+05 31 128 3218.45 0.00934981 1.96e+06 32 132 612.703 0.0186996 3.01e+06 33 136 13.0998 0.0253882 3.05e+06 34 140 0.0762922 0.00154002 5.05e+04 35 144 0.0731652 3.61102E-06 29.9 36 148 0.0731652 6.32265E-08 0.08 0.063本地最小值。LSQNONLIN停止了,因为平方与其初始值的最终变化小于函数公差的值。
CustomModel = Type: Zero Settle: 733528 (30-Apr-2008) Compounding: 2 Basis: 0 (actual/actual)
输入参数
类型
—利率曲线的类型
角色向量有价值'零'
,'forward'
, or'折扣'
利率曲线的类型, specified by using a scalar character vector.
Data Types:char
Settle
—结算日期的利率curve
日期字符向量|序列日期编号
结算日期的利率curve, specified using a scalar date character vector or serial date number.
Data Types:双倍的
|char
FunctionHandle
—Function handle that defines the interest-rate curve
function handle
使用函数句柄指定的定义利率曲线的函数句柄。该功能句柄需要两个数字向量(到期时间和功能系数的向量),并返回一个数字输出(利率或折现因子)。有关定义函数句柄的更多信息,请参见MATLAB®Programming Fundamentals documentation.
Data Types:function_handle
乐器s
—乐器s
matrix
仪器,使用N
-经过-4
数据矩阵第一列是Settle
date, the second column is到期
, the third column is the clean price, and the fourth column is a优惠券比例
for the bond.
Data Types:双倍的
irfitoptionsobj
—IRFitOptions object
IRFitOptions
object
IRFitOptions
对象,使用先前创建的对象指定的对象使用IRFitOptions
.
Data Types:object
Name-Value Arguments
将可选的参数对Name1=Value1,...,NameN=ValueN
, 在哪里Name
是the argument name and价值
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
例子:CurveObj= IRFunctionCurve.fitFunction('Zero',CurveSettle,functionHandle,Instruments,IRFitOptions([.05 .05 .05],'FitType','price','OptOptions',OptOptions))
复合
—复合frequency per-year forIRFunctionCurve
object
CurveObj.Compounding
(default) |possible values include:–1
,0
,1
,2
,3
,4
,6
,12
.
复合frequency per-year for theIRFunctionCurve
object, specified as the comma-separated pair consisting of“复合”
和a scalar numeric using one of the supported values:
−1
= Continuous compounding0
= Simple interest (no compounding)1
=年度复合2
=半年度复合3
=每年复合三次4
=季度复合6
= Bimonthly compounding12
=每月复合
Data Types:双倍的
基础
—Day count basis of the bond
0
(实际/实际)(default) |integer from0
to13
Day count basis of the bond, specified as the comma-separated pair consisting of'基础'
和标量整数。
0-实际/实际/实际
1 - 30/360(SIA)
2 - 实际/360
3 - 实际/365
4 - 30/360(PSA)
5 - 30/360(ISDA)
6 — 30/360 (European)
7 — actual/365 (Japanese)
8 - 实际/实际(ICMA)
9 - 实际/360(ICMA)
10 — actual/365 (ICMA)
11 - 30/360E(ICMA)
12 — actual/365 (ISDA)
13 - 巴士/252
有关更多信息,请参阅基础.
Data Types:双倍的
乐器Period
—Coupons per year for the bond
2
(default) |具有价值的数字0
,1
,2
,3
,4
,6
, 和12
债券每年的优惠券,指定为逗号分隔对“仪器period'
和a scalar numeric value.
Data Types:双倍的
仪器节目
—Day-count basis of the bond
0
(实际/实际)(default) |integer from0
to13
Day count basis of the bond, specified as the comma-separated pair consisting of“仪器基金”
和标量整数。
0-实际/实际/实际
1 - 30/360(SIA)
2 - 实际/360
3 - 实际/365
4 - 30/360(PSA)
5 - 30/360(ISDA)
6 — 30/360 (European)
7 — actual/365 (Japanese)
8 - 实际/实际(ICMA)
9 - 实际/360(ICMA)
10 — actual/365 (ICMA)
11 - 30/360E(ICMA)
12 — actual/365 (ISDA)
13 - 巴士/252
Note
仪器节目
区分债券仪器基础
value from the interest-rate curve's基础
value.
有关更多信息,请参阅基础.
Data Types:双倍的
乐器EndMonthRule
—月底规则
1
(default) |logical with value0
或者1
月底规则, specified as the comma-separated pair consisting of'InstrumentEndMonthRule'
和a logical value. This rule applies only when到期
是an end-of-month date for a month having 30 or fewer days.
0
= ignore rule, meaning that a bond's coupon payment date is always the same numerical day of the month.1
=set
rule on (default), meaning that a bond's coupon payment date is always the last actual day of the month.
Data Types:logical
乐器IssueDate
—乐器是sue date
[]
(default) |日期字符向量|序列日期编号
仪器发行日期,指定为逗号分隔对'InstrumentIssueDate'
和标量日期字符向量或序列日期编号。
Data Types:char
|双倍的
乐器FirstCouponDate
—Date when a bond makes its first coupon payment
cash flow payment dates are determined from other inputs(default) |日期字符向量|序列日期编号
债券进行第一张优惠券付款的日期(债券有不规则的第一张优惠券时期),指定为逗号分隔对“仪器firstcoupdate”
和标量日期字符向量或序列日期编号。什么时候乐器FirstCouponDate
和乐器LastCouponDate
都指定,乐器FirstCouponDate
takes precedence in determining the coupon payment structure. If you do not specify a乐器FirstCouponDate
,现金流付款日期由其他投入确定。
Data Types:char
|双倍的
乐器LastCouponDate
—到期日之前的债券的最后一张优惠券日期
cash flow payment dates are determined from other inputs(default) |日期字符向量|序列日期编号
到期日之前的债券的最后一张优惠券日期(当债券的最后一票期不规则时使用),指定为逗号分隔的一对'InstrumentLastCouponDate'
和标量日期字符向量或序列日期编号。在没有指定的情况下乐器FirstCouponDate
,指定乐器LastCouponDate
determines the coupon structure of the bond. The coupon structure of a bond is truncated at the乐器LastCouponDate
,无论它在哪里掉落,仅此后才是债券的成熟现金流日期。如果您不指定乐器LastCouponDate
,现金流付款日期由其他投入确定。
Data Types:char
|双倍的
乐器面
—面值或标准价值
100
(default) |数字
面值或标准价值, specified as the comma-separated pair consisting of'InstrumentFace'
和标量数字。
Data Types:双倍的
Note
什么时候using乐器
名称值对,您可以通过指定债券指定简单的兴趣乐器Period
value as0
. If仪器节目
和乐器Period
未为债券指定,使用以下默认值:仪器节目
是0
(法案/法案)和乐器Period
是2
.
Output Arguments
CurveObj
— Curve model
结构体
Curve model, returned as a structure.
Version History
Beispiel öffnen
Sie HabenEineGeänderte版本死亡。möchtensie dieses beispiel mit ihrenänderungenÖffnen?
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
führensie den befehl durch eingabe在das matlab-befehlsfenster aus中。webbrowserunterstützenkeine matlab-befehle。
选择一个网站
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:.
您还可以从以下列表中选择一个网站:
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.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)