MATLAB: How the oasbyhw function supports for stepped coupon bonds

Financial Instruments Toolbox

The documentation for "oasbyhw" function suggests that the stepped coupon bonds are supported, but I can't find that in the linked help page (https://www.mathworks.com/help/fininst/oasbyhw.html# ).
Can you point me in the right direction?

Best Answer

The help documentation for "oasbyhw" function doesn't provide an example of how to use stepped coupon bonds. Below is a simple demo that could help you understand the usage of this feature, the key part is providing the coupon schedule as part of the "CouponRate" input.
% Zero Curve
Settle = datenum('15-Jun-2020');
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = datemnth(Settle,[6 12*[1 2 3 4 5 7 10 20 30]]');
myRC = intenvset('Rates',ZeroRates,'StartDate',Settle,'EndDates',ZeroDates,...
'Basis',3,'Compounding',1);
% Bond information
CouponRate = {{'15-Jun-2025' .02;'15-Jun-2040' .03}};
Maturity = datenum('15-Jun-2040');
Price = 90;
ExerciseDates = [datenum('15-Jun-2034') datenum('15-Jun-2035') datenum('15-Jun-2036')];
Strikes = 100;
Period = 1;
% Build HW tree
AlphaHW = .1;
VolHW = .01;
myVolSpec = hwvolspec(Settle,Maturity,VolHW,Maturity,AlphaHW);
myTimeSpec = hwtimespec(Settle,cfdates(Settle,Maturity,Period),Period);
myHWTree = hwtree(myVolSpec,myRC,myTimeSpec);
% Compute OAS
[OAS,OAD,OAC] = oasbyhw(myHWTree,Price,CouponRate,Settle,Maturity,'call',Strikes,ExerciseDates,'Period')