www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceanAmortizingFloatingRateNoteExample.m
%% Price an Amortizing Floating-Rate Note % Price an amortizing floating-rate note using the |Principal| input argument % to define the amortization schedule. % Copyright 2015 The MathWorks, Inc. %% % Create the |RateSpec|. Rates = [0.03583; 0.042147; 0.047345; 0.052707; 0.054302]; ValuationDate = '15-Nov-2011'; StartDates = ValuationDate; EndDates = {'15-Nov-2012';'15-Nov-2013';'15-Nov-2014' ;'15-Nov-2015';'15-Nov-2016'}; Compounding = 1; RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding) %% % Create the floating-rate instrument using the following data: Settle ='15-Nov-2011'; Maturity = '15-Nov-2015'; Spread = 15; %% % Define the floating-rate note amortizing schedule. Principal ={{'15-Nov-2012' 100;'15-Nov-2013' 70;'15-Nov-2014' 40;'15-Nov-2015' 10}}; %% % Build the BDT tree and assume volatility is 10%. MatDates = {'15-Nov-2012'; '15-Nov-2013';'15-Nov-2014';'15-Nov-2015';'15-Nov-2016';'15-Nov-2017'}; BDTTimeSpec = bdttimespec(ValuationDate, MatDates); Volatility = 0.10; BDTVolSpec = bdtvolspec(ValuationDate, MatDates, Volatility*ones(1,length(MatDates))'); BDTT = bdttree(BDTVolSpec, RateSpec, BDTTimeSpec); %% % Compute the price of the amortizing floating-rate note. Price = floatbybdt(BDTT, Spread, Settle, Maturity, 'Principal', Principal)