www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/PriceaCallableBondUsinganHWInterestRateTreeModelExample.m
%% Price a Callable Bond Using an HW Interest-Rate Tree Model % Copyright 2015 The MathWorks, Inc. %% % Create a |HWTree| with the following data: ZeroRates = [ 0.035;0.04;0.045]; Compounding = 1; StartDates = ['jan-1-2007';'jan-1-2008';'jan-1-2009']; EndDates = ['jan-1-2008';'jan-1-2009';'jan-1-2010']; ValuationDate = 'jan-1-2007'; %% % Create a |RateSpec|. RateSpec = intenvset('Rates', ZeroRates, 'StartDates', ValuationDate, 'EndDates', ... EndDates, 'Compounding', Compounding, 'ValuationDate', ValuationDate) %% % Create a |VolSpec|. VolDates = ['jan-1-2008';'jan-1-2009';'jan-1-2010']; VolCurve = 0.01; AlphaDates = 'jan-1-2010'; AlphaCurve = 0.1; HWVolSpec = hwvolspec(ValuationDate, VolDates, VolCurve, AlphaDates, AlphaCurve) %% % Create a |TimeSpec|. HWTimeSpec = hwtimespec(ValuationDate, EndDates, Compounding) %% % Build the |HWTree|. HWTree = hwtree(HWVolSpec, RateSpec, HWTimeSpec) %% % Compute the price of an American puttable bond that pays an annual coupon % of 5.25%, matures on January 1, 2010, and is puttable from January 1, % 2008 to January 1, 2010. BondSettlement = 'jan-1-2007'; BondMaturity = 'jan-1-2010'; CouponRate = 0.0525; Period = 1; OptSpec = 'put'; Strike = [100]; ExerciseDates = {'jan-1-2008' '01-Jan-2010'}; AmericanOpt = 1; PricePutBondHW = optembndbyhw(HWTree, CouponRate, BondSettlement, BondMaturity,... OptSpec, Strike, ExerciseDates,'Period', 1, 'AmericanOpt', 1)