Этот пример иллюстрирует, как Financial Toolbox™ и Financial Instruments Toolbox™ используются, чтобы оценить ипотеку уровня поддержанная безопасность с помощью модели BDT.
load mbsexample.mat
Визуализируйте эволюцию процентной ставки вдоль дерева путем рассмотрения структуры output BDTTree
. BDTTree
возвращает обратное дисконтное дерево, которое можно преобразовать в дерево процентной ставки с cvtree
функция.
BDTTreeR = cvtree(BDTTree);
Посмотрите на верхнюю ветвь и более низкие пути к ветви дерева:
OldFormat = get(0, 'format'); format short %Rate at root node: RateRoot = treepath(BDTTreeR.RateTree, 0)
RateRoot = 0.0399
%Rates along upper branch:
RatePathUp = treepath(BDTTreeR.RateTree, [1 1 1 1 1])
RatePathUp = 6×1
0.0399
0.0397
0.0391
0.0383
0.0373
0.0360
%Rates along lower branch:
RatePathDown = treepath(BDTTreeR.RateTree, [2 2 2 2 2])
RatePathDown = 6×1
0.0399
0.0470
0.0550
0.0638
0.0734
0.0841
Скажем, то, что у нас есть 3-летний уровень за 10 000$ предподлежащая оплате ссуда с процентной ставкой по ипотечным кредитам 4,64%, раз в полгода составляемых.
MortgageAmount = 10000; CouponRate = 0.0464; Period = 2; Settle='01-Jan-2007'; Maturity='01-Jan-2010'; Compounding = BDTTree.TimeSpec.Compounding; format bank
Используйте функциональный amortize
в Financial Toolbox, чтобы вычислить ипотечный платеж ссуды (MP), интерес и основные компоненты и выдающийся основной баланс.
NumPeriods = date2time(Settle,Maturity, Compounding)';
[Principal, InterestPayment, OutstandingBalance, MP] = amortize(CouponRate/Period, NumPeriods, MortgageAmount);
% Display Principal, Interest and Outstanding balances
PrincipalAmount = Principal'
PrincipalAmount = 6×1
1572.59
1609.07
1646.40
1684.60
1723.68
1763.67
InterestPaymentAmount = InterestPayment'
InterestPaymentAmount = 6×1
232.00
195.52
158.19
119.99
80.91
40.92
OutstandingBalanceAmount =OutstandingBalance'
OutstandingBalanceAmount = 6×1
8427.41
6818.34
5171.94
3487.35
1763.67
0.00
CFlowAmounts = MP*ones(1,NumPeriods); % The CFlowDates are the same as the tree level dates CFlowDates= {'01-Jul-2007' ,'01-Jan-2008' ,'01-Jul-2008' , '01-Jan-2009' , '01-Jul-2009' , '01-Jan-2010'} ; % Calculate the price of the non-prepayable mortgage [PriceNonPrepayableMortgage, PriceTreeNonPrepayableMortgage] = cfbybdt(BDTTree, CFlowAmounts, CFlowDates, Settle); for iLevel = 2:length(PriceTreeNonPrepayableMortgage.PTree) PriceTreeNonPrepayableMortgage.PTree{iLevel}(:,:)= PriceTreeNonPrepayableMortgage.PTree{iLevel}(:,:) - MP; end % Look at the price of the mortgage today tObs = 0 PriceNonPrepayableMortgage
PriceNonPrepayableMortgage = 10017.47
% The value of the non-prepayable mortgage is $10017.47. This value exceeds % the $10000 amount borrowed since the homeowner received not only $10000, but % also a prepayment option. % Look at the value of the mortgage on the last date, right after the last % mortgage payment, is zero: PriceTreeNonPrepayableMortgage.PTree{end}
ans = 1×6
0 0 0 0 0 0
% Visualize the price tree for the non-prepayable mortgage.
treeviewer(PriceTreeNonPrepayableMortgage)
% The Prepayment option is like a call option on a bond. % % The exercise price or strike will be equal to the outstanding principal amount % which has been calculated using the function |amortize|. OptSpec = 'call'; Strike = [MortgageAmount OutstandingBalance]; ExerciseDates =[Settle CFlowDates]; AmericanOpt = 0; Maturity = CFlowDates(end); % Compute the price of the prepayment option: [PricePrepaymentOption, PriceTreePrepaymentOption] = prepaymentbybdt(BDTTree, OptSpec, Strike, ExerciseDates, AmericanOpt, ... 0, Settle, Maturity,[], [], [], ... [], [], [], [], 0, [], CFlowAmounts); % Look at the price of the prepayment option today (tObs = 0) PricePrepaymentOption
PricePrepaymentOption = 17.47
% The value of the prepayment option is $17.47 as expected. % Visualize the price tree for the prepayment option treeviewer(PriceTreePrepaymentOption)
% Compute the price of the prepayable mortgage. PricePrepayableMortgage = PriceNonPrepayableMortgage - PricePrepaymentOption; PriceTreePrepayableMortgage = PriceTreeNonPrepayableMortgage; for iLevel = 1:length(PriceTreeNonPrepayableMortgage.PTree) PriceTreePrepayableMortgage.PTree{iLevel}(:,:)= PriceTreeNonPrepayableMortgage.PTree{iLevel}(:,:) - ... PriceTreePrepaymentOption.PTree{iLevel}(:,:); end % Look at the price of the prepayable mortgage today (tObs = 0) PricePrepayableMortgage
PricePrepayableMortgage = 10000.00
% The value of the prepayable mortgage is $10000 as expected. % Visualize the price and price tree for the prepayable mortgage treeviewer(PriceTreePrepayableMortgage)
set(0, 'format', OldFormat);
mbscfamounts
| mbsconvp
| mbsconvy
| mbsdurp
| mbsdury
| mbsnoprepay
| mbsoas2price
| mbsoas2yield
| mbspassthrough
| mbsprice
| mbsprice2oas
| mbsprice2speed
| mbswal
| mbsyield
| mbsyield2oas
| mbsyield2speed
| psaspeed2default
| psaspeed2rate