www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PricefloatbybkAmortizingFloatingRateNoteExample.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 BK tree and assume the volatility is 10%. VolDates = ['15-Nov-2012'; '15-Nov-2013';'15-Nov-2014';'15-Nov-2015';'15-Nov-2016';'15-Nov-2017']; VolCurve = 0.1; AlphaDates = '15-Nov-2017'; AlphaCurve = 0.1; BKVolSpec = bkvolspec(RateSpec.ValuationDate, VolDates, VolCurve,... AlphaDates, AlphaCurve); BKTimeSpec = bktimespec(RateSpec.ValuationDate, VolDates, Compounding); BKT = bktree(BKVolSpec, RateSpec, BKTimeSpec); %% % Compute the price of the amortizing floating-rate note. Price = floatbybk(BKT, Spread, Settle, Maturity, 'Principal', Principal)