Этот пример иллюстрирует, как 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
Скажем, то, что у нас есть трехлетний уровень за 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
1.5726
1.6091
1.6464
1.6846
1.7237
1.7637
InterestPaymentAmount = InterestPayment'
InterestPaymentAmount = 6×1
232.0000
195.5160
158.1856
119.9891
80.9065
40.9171
OutstandingBalanceAmount = OutstandingBalance'
OutstandingBalanceAmount = 6×1
8.4274
6.8183
5.1719
3.4873
1.7637
0.0000
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
| mbspassthrough
| mbsprice
| mbswal
| mbsyield
| mbsprice2speed
| mbsyield2speed
| psaspeed2default
| psaspeed2rate
| mbsoas2price
| mbsoas2yield
| mbsprice2oas
| mbsyield2oas