这个例子展示了创建债券和债券期权工具投资组合并为其定价的工作流程。您可以使用finportfolio
和pricePortfolio
价格FixedBond
,FixedBondOption
,OptionEmbeddedFixedBond
,FloatBond
仪器使用一个IRTree
定价方法。
ratecurve
对象创建一个ratecurve
对象使用ratecurve
.
清算= datetime(2018,1,1);ZeroTimes = calyears(1:4)”;ZeroRates = (0.035;0.042147;0.047345;0.052707);ZeroDates = Settle + ZeroTimes;复合= 1;ZeroCurve = ratecurve (“零”、结算、ZeroDates ZeroRates,“复合”复合)
0曲线=利率曲线与属性:类型:“零”复利:1基础:0日期:[4x1 datetime]利率:[4x1 double]解决:2018年1月1日
使用fininstrument
创建一个FixedBond
,FixedBondOption
,OptionEmbeddedFixedBond
,FloatBond
仪的对象。
CDates = 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 =固定绑定属性:CouponRate: 0.0425周期:1基础:0 EndMonthRule: 1 Principal: 100 DaycountAdjustedCashFlow: 0 BusinessDayConvention:“实际”假期:NaT issueddate: NaT FirstCouponDate: NaT LastCouponDate: NaT StartDate: NaT成熟度:01- 1- 2022名称:“vanilla_fixed”
步进息票债券SBond = fininstrument (“FixedBond”,“成熟”成熟,“CouponRate”CouponRate,“时间”期,“名字”,“stepped_coupon_bond”)
SBond =固定债券与属性:CouponRate: [2x1时间表]周期:1基础: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”)
CallOption = FixedBondOption with properties: OptionType: "call" ExerciseStyle: "american" ExerciseDate: 01-Jan-2020 Strike: 100 Bond: [1x1 fininstrument.]FixedBond)名称:“fixed_bond_option”
%内嵌债券(可赎回债券)选项CDates = 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与属性:CouponRate: [2x1时间表]周期:1基础: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时间表]CallExerciseStyle: "american" PutExerciseStyle: [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
的Pricer对象HullWhite
建模并使用ratecurve
对象的“DiscountCurve”
名称-值对的论点。
HWTreePricer = finpricer (“IRTree”,“模型”HWModel,“DiscountCurve”ZeroCurve,“TreeDates”ZeroDates)
HWTreePricer = HWBKTree with properties: Tree: [1x1 struct] TreeDates: [4x1 datetime] Model: [1x1 finmodel.]DiscountCurve: [1x1利率曲线]
finportfolio
对象和添加可赎回债券工具创建一个finportfolio
对象有普通债券、阶梯息票债券、浮动债券和看涨期权。
myportfolio = finportfolio([VBond,SBond,Float,CallOption],HWTreePricer, [1,2,2,1])
工具:[4x1金融工具。FinInstrument] Pricers: [1x1 finpricer.irtree.]HWBKTree] PricerIndex: [4x1 double]数量:[4x1 double]
使用addInstrument
将可赎回债券工具添加到现有投资组合中。
myportfolio = addInstrument (myportfolio CallableBond HWTreePricer, 1)
工具:[5x1金融工具。FinInstrument] Pricers: [1x1 finpricer.irtree.]HWBKTree] PricerIndex: [5x1 double]数量:[5x1 double]
myportfolio。PricerIndex
ans =5×1111 111 111
的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 steped_coupon_bond 204.14 0.00 3364.60 -725.96 floatbond 200.00 -0.00 -0.00 0.00 fixed_bond_option 0.05 12.48 24.15 -3.69 option_embedded_fixedbond 99.77 -75.88 767.41 -223.03