这个例子说明了金融工具箱是如何工作的™ 金融工具工具箱™ 用于使用BDT模型为a级抵押担保证券定价。
负载mbsexample.mat
通过查看输出结构,将利率沿树的演变可视化BDTTree
.BDTTree
返回一个反向折扣树,您可以使用cvtree
功能。
BDTTreeR = cvtree (BDTTree);
看看树的上分支和下分支路径:
OldFormat=get(0,“格式”);格式短的%根节点上的速率:RateRoot=treepath(BDTTreeR.RateTree,0)
RateRoot=0.0399
%沿上分支的费率:ratepath=treepath(BDTTreeR.RateTree[1])
RatePathUp =6×10.0399 0.0397 0.0391 0.0383 0.0373 0.0360
%沿下支路的费率:RatePathDown=treepath(BDTTreeR.RateTree[2])
RatePathDown =6×10.0399 0.0470 0.0550 0.0638 0.0734 0.0841
假设我们有一笔3年期10000美元的预付贷款,抵押贷款利率为4.64%,半年复利。
MortgageAmount = 10000;CouponRate = 0.0464;时间= 2;解决=‘01-Jan-2007’;成熟度=‘2010年1月1日’;复合=BDTTree.TimeSpec.compositioning;格式银行
使用的函数摊销
在Financial Toolbox™中计算贷款的抵押付款(MP),利息和主要成分,以及未偿还的本金余额。
NumPeriods = date2time(结算,到期日,复利)';[本金,利息支付,未偿余额,MP] =摊销(CouponRate/Period, NumPeriods, MortgageAmount);显示本金、利息和未偿余额PrincipalAmount=主体'
PrincipalAmount =6×11.5726 1.6091 1.6464 1.6846 1.7237 1.7637
InterestPaymentAmount=InterestPayment'
利息支付额=6×1232.0000 195.5160 158.1856 119.9891 80.9065 40.9171
OutstandingBalanceAmount = OutstandingBalance '
OutstandingBalanceAmount =6×18.4274 6.8183 5.1719 3.4873 1.7637 0.0000
CFlowAmounts=MP*个(1,NumPeriods);CFlowDates与树级别的日期相同CFlowDates={‘2007年7月1日’,' 01 - 1月- 2008,‘2008年7月1日’,' 01 - 1月- 2009,‘01-Jul-2009’,‘2010年1月1日’} ;%计算不可预付抵押贷款的价格[PriceNonPrepayableMortgage, PriceTreeNonPrepayableMortgage] = cfbybdt(BDTTree, cflowamount, CFlowDates,结算);对于PriceTreeNonPrepayableMortgage.PTree = 2:length(PriceTreeNonPrepayableMortgage.PTree) PriceTreeNonPrepayableMortgage.PTree{level}(:,:)= PriceTreeNonPrepayableMortgage.PTree;结束%看看今天抵押贷款的价格tObs=0无息抵押贷款
价格不可偿还抵押贷款=10017.47
%不可预付抵押贷款的价值为10017.47美元。该价值超过%贷款的10000美元,因为房主不仅收到了10000美元,而且%也是一种预付款选择。%看看抵押贷款在最后一天的价值,就在最后一天之后%抵押付款为零:PriceTreeNonPrepayableMortgage.PTree{end}
ans=1×60 0 0 0 0 0
%想象不可预付抵押贷款的价格树。treeview (PriceTreeNonPrepayableMortgage)
%提前还款期权就像债券上的看涨期权。%%行权价格或行权将等于未偿本金金额%,使用摊销函数计算。OptSpec=“电话”;罢工=[抵押金额未偿余额];行使日期=[结算日期];美国债券=0;到期日期=结算日期(结束);%计算预付款期权的价格:[PricePrepaymentOption, PriceTreePrepaymentOption] = prepaymentbybdt(BDTTree, OptSpec, Strike, ExerciseDates, AmericanOpt,...0,结算,到期,[],[],[],...[]、[]、[]、[]、[]、0、[]、CFlowAmounts);%看看今天的提前支付期权价格(tObs = 0)PricePrepaymentOption
价格预付选项=17.47
%预付期权的价值如预期的那样为17.47美元。%可视化预付款选项的价格树treeviewer(PriceTreePrepaymentOption)
%计算可预付抵押贷款的价格。PricePrepableMortage=PriceNonprableMortage-PricePrepableMortage选项;PriceTreePrepableMortage=PriceTreeNonPrableMortage;对于iLevel=1:length(priceTreeNonPrayablemortgage.PTree)priceTreePrepablemortgage.PTree{iLevel}(:,:)=PriceTreeNonPrayablemortgage.PTree{iLevel}(:,:)-...PriceTreePrepaymentOption.PTree{iLevel}(:,:);结束%看看今天可预付抵押贷款的价格(tObs=0)可提前偿还抵押贷款
价格预付抵押=10000.00
按预期,预付抵押贷款的价值是10000美元。%想象预付抵押贷款的价格和价格树treeviewer(PriceTreePrepayableMortgage)
设置(0,“格式”, OldFormat);
mbscfamounts
|mbsconvp
|mbsconvy
|mbsdurp
|姆布斯杜里
|mbsnoprepay
|mbspassthrough
|mbsprice
|mbswal
|姆斯菲尔德
|mbsprice2速度
|MBSYIELD2速度
|psaspeed2default
|psa2rate
|MBSOAS2价格
|MBSOAS2产量
|mbsprice2oas
|mbsyield2oas