www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceSwapBySpecifyingMultipleTermStructuresUsinga1by2RatExample.m
%% Price Swap By Specifying Multiple Term Structures Using a 1-by-2 |RateSpec| % Price a swap using two interest-rate curves. First, define data for the two interest-rate term structures: % Copyright 2015 The MathWorks, Inc. %% StartDates = '01-May-2012'; EndDates = {'01-May-2013'; '01-May-2014';'01-May-2015';'01-May-2016'}; Rates1 = [0.0356;0.041185;0.04489;0.047741]; Rates2 = [0.0366;0.04218;0.04589;0.04974]; %% % Create the |RateSpec| using |intenvset|. RateSpecReceiving = intenvset('Rates', Rates1, 'StartDates',StartDates,... 'EndDates', EndDates, 'Compounding', 1); RateSpecPaying= intenvset('Rates', Rates2, 'StartDates',StartDates,... 'EndDates', EndDates, 'Compounding', 1); RateSpec=[RateSpecReceiving RateSpecPaying] %% % Define the swap instruments. Settle = '01-May-2012'; Maturity = '01-May-2015'; LegRate = [0.06 10]; Principal = [100;50;100]; %% % Price three swaps using the two curves. Price = swapbyzero(RateSpec, LegRate, Settle, Maturity, 'Principal', Principal)