www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceAmortizingSwapExample.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 BDT tree and assume volatility is 10%. MatDates = {'1-Jan-2012'; '1-Jan-2013';'1-Jan-2014';'1-Jan-2015';'1-Jan-2016';'1-Jan-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 swap. Price = swapbybdt(BDTT, LegRate, Settle, Maturity, 'Principal' , Principal)