www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceanAmortizSwapExample.m
%% Price an Amortizing Swap % Price an amortizing swap using the |Principal| input argument to define % the amortization schedule. % Copyright 2015 The MathWorks, Inc. %% % Create the |RateSpec|. Rates = 0.035; ValuationDate = '1-Jan-2011'; StartDates = ValuationDate; EndDates = '1-Jan-2017'; Compounding = 1; RateSpec = intenvset('ValuationDate', ValuationDate,'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding) %% % Create the swap instrument using the following data: Settle ='1-Jan-2011'; Maturity = '1-Jan-2017'; Period = 1; LegRate = [0.04 10]; %% % Define the swap amortizing schedule. Principal ={{'1-Jan-2013' 100;'1-Jan-2014' 80;'1-Jan-2015' 60;'1-Jan-2016' 40; '1-Jan-2017' 20}}; %% % Build the HW tree using the following data: VolDates = ['1-Jan-2012'; '1-Jan-2013';'1-Jan-2014';'1-Jan-2015';'1-Jan-2016';'1-Jan-2017']; VolCurve = 0.1; AlphaDates = '01-01-2017'; AlphaCurve = 0.1; HWVolSpec = hwvolspec(RateSpec.ValuationDate, VolDates, VolCurve,... AlphaDates, AlphaCurve); HWTimeSpec = hwtimespec(RateSpec.ValuationDate, VolDates, Compounding); HWT = hwtree(HWVolSpec, RateSpec, HWTimeSpec); %% % Compute the price of the amortizing swap. Price = swapbyhw(HWT, LegRate, Settle, Maturity, 'Principal', Principal)