www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PricefloatbybkCollarwithaFloatingRateNoteExample.m
%% Price a Collar with a Floating-Rate Note % Price a collar with a floating-rate note using the |CapRate| and |FloorRate| % input argument to define the collar pricing. % Copyright 2015 The MathWorks, Inc. %% % Price a portfolio of collared floating-rate notes using the following data: Rates = [0.0287; 0.03024; 0.03345; 0.03861; 0.04033]; ValuationDate = '1-April-2012'; StartDates = ValuationDate; EndDates = {'1-April-2013';'1-April-2014';'1-April-2015' ;... '1-April-2016';'1-April-2017'}; Compounding = 1; %% % Create the |RateSpec|. RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding); %% % Build the BK tree and assume the volatility to be 5%. VolDates = ['1-April-2013';'1-April-2014';'1-April-2015';'1-April-2016';... '1-April-2017';'1-April-2018']; VolCurve = 0.05; AlphaDates = '15-Nov-2018'; AlphaCurve = 0.1; BKVolSpec = bkvolspec(RateSpec.ValuationDate, VolDates, VolCurve,... AlphaDates, AlphaCurve); BKTimeSpec = bktimespec(RateSpec.ValuationDate, VolDates, Compounding); BKT = bktree(BKVolSpec, RateSpec, BKTimeSpec); %% % Create the floating-rate note instrument. Settle ='1-April-2012'; Maturity = '1-April-2016'; Spread = [15;10]; Principal = 100; %% % Compute the price of the two vanilla floaters. Price = floatbybk(BKT, Spread, Settle, Maturity) %% % Compute the price of the collared floating-rate notes. CapStrike = {{'1-April-2013' 0.045; '1-April-2014' 0.05;... '1-April-2015' 0.06}; 0.06}; FloorStrike = {{'1-April-2013' 0.035; '1-April-2014' 0.04;... '1-April-2015' 0.05}; 0.03}; PriceCollared = floatbybk(BKT, Spread, Settle, Maturity,... 'CapRate', CapStrike,'FloorRate', FloorStrike)