%% Compute Margin Measures for a Floating-Rate Bond
% Use floatmargin to compute margin measures for spreadforlife, adjustedsimple, and adjustedtotal for a floating-rate note.
% Define data for the floating-rate note.

Price = 99.99;
Spread = 50;
Settle = '20-Jan-2011';
Maturity = '15-Jan-2012';
LatestFloatingRate = 0.05;
StubRate = 0.049;
SpotRate = 0.05;
Reset = 4;
Basis = 2;

%
% Calculate spreadforlife.

Margin = floatmargin(Price, Spread, Settle, Maturity, 'Reset', ...
Reset, 'Basis', Basis)

%
% Calculate adjustedsimple margin.

[Margin, AdjPrice] = floatmargin(Price, Spread, Settle, Maturity, ...
'SpreadType', 'adjustedsimple', 'RateInfo', [StubRate, SpotRate], ...
'LatestFloatingRate', LatestFloatingRate, 'Reset', Reset, 'Basis', Basis)

%
% Calculate adjustedtotal margin.

[Margin, AdjPrice] = floatmargin(Price, Spread, Settle, Maturity, ...
'SpreadType', 'adjustedtotal', 'RateInfo', [StubRate, SpotRate], ...
'LatestFloatingRate', LatestFloatingRate, 'Reset', Reset, 'Basis', Basis)

% Copyright 2015 The MathWorks, Inc.