主要内容

债券和债券期权工具的价格组合

这个示例展示了创建债券和债券期权工具投资组合并为其定价的工作流程。您可以使用finportfoliopricePortfolio价格FixedBondFixedBondOptionOptionEmbeddedFixedBond,FloatBond仪器使用一个IRTree定价方法。

创建ratecurve对象

创建一个ratecurve对象使用ratecurve

set = datetime(2018, 1,1);ZeroTimes = calyears(1:4)”;ZeroRates = (0.035;0.042147;0.047345;0.052707);zeroates = Settle + ZeroTimes;复合= 1;ZeroCurve = ratecurve (“零”、结算、ZeroDates ZeroRates,“复合”复合)
ZeroCurve =带有属性的比率曲线:类型:" 0 "复利:1基础:0日期:[4x1 datetime]率:[4x1 double]定:01- 2018年1月InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"

创建债券和期权工具

使用fininstrument创建一个FixedBondFixedBondOptionOptionEmbeddedFixedBond,FloatBond仪的对象。

cdate = datetime([2020,1,1;2022年,1,1);箱= [.0425;.0750];CouponRate =时间表(CDates、箱);成熟= datetime(2022、1、1);时间= 1;%香草FixedBondVBond = fininstrument (“FixedBond”“成熟”成熟,“CouponRate”, 0.0425,“时间”期,“名字”“vanilla_fixed”
VBond = FixedBond with properties: CouponRate: 0.0425 Period: 1 Basis: 0 EndMonthRule: 1 Principal: 100 DaycountAdjustedCashFlow: 0 BusinessDayConvention:“实际”假期:NaT issueddate: NaT FirstCouponDate: NaT LastCouponDate: NaT StartDate: NaT Maturity: 01-Jan-2022名称:“vanilla_fixed”
阶梯式息票债券SBond = fininstrument (“FixedBond”“成熟”成熟,“CouponRate”CouponRate,“时间”期,“名字”“stepped_coupon_bond”
SBond = FixedBond with properties: CouponRate: [2x1时间表]Period: 1 Basis: 0 EndMonthRule: 1 Principal: 100 DaycountAdjustedCashFlow: 0 BusinessDayConvention: "实际"假期:NaT issueddate: NaT FirstCouponDate: NaT LastCouponDate: NaT StartDate: NaT Maturity: 01- jan 2022名称:"stepped_coupon_bond"
% FloatBond传播= 0;重置= 1;浮动= fininstrument (“FloatBond”“成熟”成熟,“传播”传播,“重置”重置,...“ProjectionCurve”ZeroCurve,“名字”“floatbond”
浮动= FloatBond属性:传播:0 ProjectionCurve: [1 x1 ratecurve] ResetOffset: 0重置:1基础:0 EndMonthRule: 1主要:100 DaycountAdjustedCashFlow: 0 BusinessDayConvention:“实际”LatestFloatingRate:南假日:NaT IssueDate: NaT FirstCouponDate: NaT LastCouponDate: NaT StartDate可以:NaT成熟度:01 - 1月- 2022的名字:“FloatBond”
%的看涨期权罢工= 100;ExerciseDates = datetime(2020、1、1);OptionType =“电话”;时间= 1;CallOption = fininstrument (“FixedBondOption”“罢工”罢工,“ExerciseDate”ExerciseDates,...“OptionType”OptionType,“ExerciseStyle”“美国”“债券”VBond,“名字”“fixed_bond_option”
期权类型:"call" exercisstyle: "american" exercisdate: 01-Jan-2020 Strike: 100 Bond: [1x1 fininstrument。FixedBond)名称:“fixed_bond_option”
嵌入债券(可赎回债券)%选择cdate = datetime([2020,1,1;2022年,1,1);箱= [.0425;.0750];CouponRate =时间表(CDates、箱);StrikeOE = [100;100);ExerciseDatesOE = [datetime(2020年,1,1);datetime(2021年,1,1)];CallSchedule =时间表(ExerciseDatesOE StrikeOE,“VariableNames”, {“罢工计划”});CallableBond = fininstrument (“OptionEmbeddedFixedBond”“成熟”成熟,...“CouponRate”CouponRate,“时间”期,...“CallSchedule”CallSchedule,“名字”“option_embedded_fixedbond”
CallableBond = OptionEmbeddedFixedBond with properties: CouponRate: [2x1时间表]Period: 1 Basis: 0 EndMonthRule: 1 Principal: 100 DaycountAdjustedCashFlow: 0 BusinessDayConvention:“实际”假期:NaT IssueDate: NaT FirstCouponDate: NaT LastCouponDate: NaT StartDate: NaT Maturity: 01-Jan-2022 CallDates: [2x1 datetime] PutDates:[0x1 datetime] CallSchedule: [2x1时刻表]PutSchedule: [0x0时刻表]callexercisstyle: "american" putexercisstyle: [0x0 string] Name: "option_embedded_fixedbond"

创建HullWhite模型

使用finmodel创建一个HullWhite模型对象。

VolCurve = 0.01;AlphaCurve = 0.1;HWModel = finmodel (“hullwhite”“α”AlphaCurve,“σ”VolCurve)
HWModel = HullWhite属性:Alpha: 0.1000 Sigma: 0.0100

创建IRTree定价的人了HullWhite模型

使用finpricer创建一个IRTree对象的PricerHullWhite建立模型并使用ratecurve对象的“DiscountCurve”名称-值对的论点。

HWTreePricer = finpricer (“IRTree”“模型”HWModel,“DiscountCurve”ZeroCurve,“TreeDates”ZeroDates)
HWTreePricer = HWBKTree with properties: Tree: [1x1 struct] TreeDates: [4x1 datetime] Model: [1x1 finmodel. HWTreePricer = HWBKTree with properties: Tree: [1x1 struct] TreeDates: [4x1 datetime] Model: [1x1 finmodel. HWTreePricer = HWBKTree折现曲线:[1x1率曲线]

创建finportfolio对象并添加可收回债券工具

创建一个finportfolio买入普通债券、阶梯式息票债券、浮动债券和看涨期权。

myportfolio = finportfolio([VBond,SBond,Float, callloption],HWTreePricer, [1,2,2,1])
myportfolio = finportfolio with properties:价格:[1x1 finpricer.irtree.]HWBKTree: PricerIndex: [4x1 double]数量:[4x1 double]

使用addInstrument将可赎回债券工具加入现有投资组合。

myportfolio = addInstrument (myportfolio CallableBond HWTreePricer, 1)
myportfolio = finportfolio with properties:价格:[1x1 finpricer.irtree.]HWBKTree: PricerIndex: [5x1 double]数量:[5x1 double]
myportfolio。PricerIndex
ans =5×11 1 1 1

PricerIndex属性中的工具对象的长度等于finportfolio对象并存储每个仪器对象使用的定价器的索引。在这种情况下,因为只有一个定价器,每个仪器都必须使用那个定价器。

价格组合

使用pricePortfolio计算投资组合以及投资组合中的债券和期权工具的价格和敏感性。

格式银行[PortPrice, InstPrice PortSens InstSens] = pricePortfolio (myportfolio)
PortPrice = 600.55
InstPrice =5×196.5943 204.1377 200.0000 0.0487 99.7738
PortSens =1×4表价格织女星γδ  ______ ______ _______ ________ 600.55 -63.40 5759.65 -1297.48
InstSens =5×4表Vega Gamma Delta ______ ______ _______ _______ vanilla_fixed 96.59 -0.00 1603.49 -344.81 stepped_coupon_bond 204.14 0.00 3364.60 -725.96 floatbond 200.00 -0.00 -0.00 0.00 fixed_bond_option