www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceabondbyhjmSteppedCouponBondExample.m
%% Price a Stepped Coupon Bond % Price single stepped coupon bonds using market data. % Copyright 2015 The MathWorks, Inc. %% % Define the interest-rate term structure. Rates = [0.035; 0.042147; 0.047345; 0.052707]; ValuationDate = 'Jan-1-2010'; StartDates = ValuationDate; EndDates = {'Jan-1-2011'; 'Jan-1-2012'; 'Jan-1-2013'; 'Jan-1-2014'}; Compounding = 1; %% % Create the |RateSpec|. RS = intenvset('ValuationDate', ValuationDate, 'StartDates', StartDates,... 'EndDates', EndDates,'Rates', Rates, 'Compounding', Compounding); %% % Create the stepped bond instrument. Settle = '01-Jan-2010'; Maturity = {'01-Jan-2011';'01-Jan-2012';'01-Jan-2013';'01-Jan-2014'}; CouponRate = {{'01-Jan-2012' .0425;'01-Jan-2014' .0750}}; Period = 1; %% % Build the HJM tree using the following market data: Volatility = [.2; .19; .18; .17]; CurveTerm = [ 1; 2; 3; 4]; HJMTimeSpec = hjmtimespec(ValuationDate, EndDates); HJMVolSpec = hjmvolspec('Proportional', Volatility, CurveTerm, 1e6); HJMT = hjmtree(HJMVolSpec,RS,HJMTimeSpec); %% % Compute the price of the stepped coupon bonds. PHJM= bondbyhjm(HJMT, CouponRate, Settle,Maturity , Period)