www.gusucode.com > fininst 案例源码程序 matlab代码 > fininst/SpreadEffectAnalysisforaConvertibleBondUsingaSTTTreeExample.m
%% Spread Effect Analysis for a Convertible Bond Using a |STTTree| % This example demonstrates the spread effect analysis of a 4% coupon convertible % bond, callable at 110 at end of the second year, maturing in five years, % with spreads of 0, 50, 100, and 150 BP. %% % Define the |RateSpec|. StartDates = '1-Apr-2015'; EndDates = '1-Apr-2020'; Rates = 0.05; Compounding = -1; Basis = 1; RateSpec = intenvset('StartDates',StartDates,'EndDates',EndDates,'Rates',Rates,... 'Compounding',Compounding,'Basis',Basis) %% % Define the convertible bond data. Settle = '1-Apr-2015'; Maturity = '1-Apr-2020'; CouponRate = 0.04; CallStrike = 110; CallExDates = [datenum('1-Apr-2017') datenum(Maturity)]; ConvRatio = 1; AmericanCall = 1; Sigma = 0.3; Spreads = 0:0.005:0.015; Prices = 40:10:140; convprice = zeros(length(Prices),length(Spreads)); %% % Define the |TimeSpec| for the Standard Trinomial Tree, create an |STTTree| % using |<docid:fininst_ug.but9r1f-1 stttree>|, and price the convertible % bond using |cbondbystt|. NumSteps = 200; TimeSpec = stttimespec(StartDates, EndDates, NumSteps); for PriceIdx = 1:length(Prices) StockSpec = stockspec(Sigma, Prices(PriceIdx)); STTT = stttree(StockSpec, RateSpec, TimeSpec); convprice(PriceIdx,:) = cbondbystt(STTT, CouponRate, Settle, Maturity, ConvRatio,... 'Spread', Spreads(:),'CallExDates', CallExDates, 'CallStrike', CallStrike,... 'AmericanCall', AmericanCall); end %% % Plot the spread effect analysis for the convertible bond. stock = repmat(Prices',1,length(Spreads)); plot(stock,convprice); legend({'+0 bp'; '+50 bp'; '+100 bp'; '+150 bp'}); title ('Effect of Spread using Trinomial tree - 200 steps') xlabel('Stock Price'); ylabel('Convertible Bond Price'); text(50, 150, ['Coupon 4% semiannual,', sprintf('\n'), ... '110 Call after 2 years,' sprintf('\n'), ... 'maturing in 5 years.'],'fontweight','Bold')