%% Set Put Execise Policy for Option Embedded Fixed Bond Instrument
% This example shows how to use setPutExercisePolicy to maintain consistency between the exercise schedule and exercise style when using a OptionEmbeddedFixedBond instrument object.
%
%% Create OptionEmbeddedFixedBond Instrument Object
% Use fininstrument to create an OptionEmbeddedFixedBond instrument object with different exercise styles.

Maturity = datetime(2024,1,1);
Strike = [100;100];
ExerciseDates = [datetime(2020,1,1); datetime(2024,1,1)];
Period = 1;
PutSchedule =  timetable(ExerciseDates,Strike,'VariableNames',{'Strike Schedule'}); 

PuttableBond = fininstrument("OptionEmbeddedFixedBond",'Maturity',Maturity,...
                              'CouponRate',0.025,'Period',Period, ...
                              'PutSchedule',PutSchedule)

%% Set Exercise Style to Bermudan
% Use setPutExercisePolicy to define PutExerciseStyle as Bermudan.

PuttableBond = setPutExercisePolicy(PuttableBond, PutSchedule, "Bermudan") 

% Use setPutExercisePolicy to modify PutSchedule and continue using a Bermudan exercise style.

Strike = [100; 101;102;103];
ExerciseDates = [datetime(2018,1,1);datetime(2020,1,1);datetime(2022,1,1);datetime(2024,1,1)];

PutSchedule =  timetable(ExerciseDates,Strike,'VariableNames',{'Strike Schedule'}); 

PuttableBond = setPutExercisePolicy(PuttableBond, PutSchedule)   

% Copyright 2020 The MathWorks, Inc.