www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceInterestRateSwapExample.m
%% Price an Interest-Rate Swap % Price an interest-rate swap with a fixed receiving leg and a floating % paying leg. Payments are made once a year, and the notional principal % amount is $100. The values for the remaining arguments are: % % * Coupon rate for fixed leg: 0.15 (15%) % * Spread for floating leg: 10 basis points % * Swap settlement date: Jan. 01, 2000 % * Swap maturity date: Jan. 01, 2003 % Copyright 2015 The MathWorks, Inc. %% % Based on the information above, set the required arguments and build the % |LegRate|, |LegType|, and |LegReset| matrices: Settle = '01-Jan-2000'; Maturity = '01-Jan-2003'; Basis = 0; Principal = 100; LegRate = [0.15 10]; % [CouponRate Spread] LegType = [1 0]; % [Fixed Float] LegReset = [1 1]; % Payments once per year %% % Price the swap using the |BDTTree| included in the MAT-file |deriv.mat|. % |BDTTree| contains the time and forward-rate information needed to price % the instrument. load deriv.mat; %% % Use |swapbybdt| to compute the price of the swap. Price = swapbybdt(BDTTree, LegRate, Settle, Maturity,... LegReset, Basis, Principal, LegType) %% % Using the previous data, calculate the swap rate, the coupon rate for % the fixed leg, such that the swap price at time = 0 is zero. LegRate = [NaN 20]; [Price, PriceTree, CFTree, SwapRate] = swapbybdt(BDTTree,... LegRate, Settle, Maturity, LegReset, Basis, Principal, LegType)