%% Compute Margin Measures for a Floating-Rate Bond Using datetime Inputs
% Use floatmargin to calculate margin measures for spreadforlife, adjustedsimple, and adjustedtotal for a floating-rate note using datetime inputs.

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;

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

% Copyright 2012 The MathWorks, Inc.